pytorch / serve

Serve, optimize and scale PyTorch models in production
https://pytorch.org/serve/
Apache License 2.0
4.22k stars 863 forks source link

✨ Add `.devcontainer` Configuration for TorchServe Development Environment #3346

Open yhna940 opened 1 month ago

yhna940 commented 1 month ago

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.

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:

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:

mreso commented 1 month ago

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 commented 1 month ago

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 commented 4 days ago

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! 😊