serve icon indicating copy to clipboard operation
serve copied to clipboard

✨ Add `.devcontainer` Configuration for TorchServe Development Environment

Open yhna940 opened this issue 1 year ago • 3 comments

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)
  • [x] 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:

  • [x] 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?

yhna940 avatar Oct 12 '24 16:10 yhna940

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.

mreso avatar Oct 14 '24 21:10 mreso

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 :)

yhna940 avatar Oct 16 '24 01:10 yhna940

Hello @mreso, I hope you're doing well! I wanted to follow up on the status of this PR. Are there any additional changes or updates you'd like me to make? Please let me know if there's anything else I can do to help move this forward. Thank you for your time and feedback! 😊

yhna940 avatar Nov 22 '24 17:11 yhna940