Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add .devcontainer Configuration for TorchServe Development Environment #3346

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

yhna940
Copy link

@yhna940 yhna940 commented Oct 12, 2024

Description

This PR introduces a .devcontainer/devcontainer.json configuration for setting up a Docker-based development environment in VS Code, specifically for TorchServe. Many libraries, such as Accelerate and PyTorch, support similar Dev Container environments, allowing for streamlined development with a consistent toolchain across contributors and platforms.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Feature/Issue validation/testing

Visual Studio Code Dev Containers

The Dev Containers extension in VS Code allows developers to use a Docker container as a fully-featured development environment. This provides a reproducible, isolated setup that can mirror production configurations, enabling:

  • Consistent toolchain and OS across development and deployment.
  • Easy swapping between environments, minimizing local machine impacts.
  • Faster onboarding for new team members with a ready-to-go environment.
  • Safe exploration of new technologies or codebases without local setup risks.

Once initialized, VS Code operates as if all tools and files were local, ensuring a seamless workflow.

  1. Install the Dev Containers Extension
    In Visual Studio Code, search for "Dev Containers" in the Extensions marketplace and install it.

image

  1. Open in Container
    After installation, you will see a pop-up similar to the one in the screenshot. Click the "Reopen in Container" button to start the development environment inside a Docker container.

image


If you want to customize the development environment further, modify the appropriate fields in .devcontainer/devcontainer.json. For example, to use a GPU-based container, you can adjust the configuration as shown below:

{
    "name": "TorchServe Dev Environment",
    "build": {
        "dockerfile": "../docker/Dockerfile",
        "context": "..",
        "args": {
            "BASE_IMAGE": "nvidia/cuda:12.1.1-base-ubuntu20.04",
            "PYTHON_VERSION": "3.9",
            "BRANCH_NAME": "master",
            "REPO_URL": "https://github.com/pytorch/serve.git",
            "CUDA_VERSION": "cu121"
        }
    },
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-python.python"
            ]
        }
    },
    "runArgs": [
        "--gpus", "all",
        "--ipc", "host"
    ]
}

With this setup, you can run a GPU-enabled TorchServe container for accelerated model serving.

Checklist:

  • Did you have fun?
  • Have you added tests that prove your fix is effective or that this feature works?
  • Has code been commented, particularly in hard-to-understand areas?
  • Have you made corresponding changes to the documentation?

@mreso
Copy link
Collaborator

mreso commented Oct 14, 2024

Hi @yhna940 thanks for the contribution! Could you add the same description you added to the PR to serve/docker/README.md and also add a line referring to that section into serve/CONTRIBUTING.md?
Thank would be very helpful for users to discover the feature.

@yhna940
Copy link
Author

yhna940 commented Oct 16, 2024

Hi @yhna940 thanks for the contribution! Could you add the same description you added to the PR to serve/docker/README.md and also add a line referring to that section into serve/CONTRIBUTING.md? Thank would be very helpful for users to discover the feature.

Hi @mreso , thank you for the review! I have updated the files as requested. Please let me know if there are any additional changes needed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants