From 63c0a061d74e9708e3dfedf36aae0fb3764aa0a4 Mon Sep 17 00:00:00 2001 From: yhna Date: Sat, 12 Oct 2024 15:42:41 +0000 Subject: [PATCH 1/5] Add devcontainer cfg --- .devcontainer/devcontainer.json | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..2b794de3b5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,30 @@ +{ + "name": "TorchServe Dev Container", + "build": { + "dockerfile": "../docker/Dockerfile", + "context": "..", + "args": { + "BASE_IMAGE": "ubuntu:20.04", + "PYTHON_VERSION": "3.9", + "BRANCH_NAME": "master", + "REPO_URL": "https://github.com/pytorch/serve.git", + "CUDA_VERSION": "" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python" + ] + } + }, + "runArgs": [ + // ACTION NEEDED: uncomment the next line if your local machine has GPUs available +// "--gpus", "all", + // Enable the docker container to access system resources + "--ipc", "host" + ], + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + } +} From 78e5e03dfe948cabd280d071c6aa796c03ed3082 Mon Sep 17 00:00:00 2001 From: yhna Date: Sun, 13 Oct 2024 00:51:40 +0900 Subject: [PATCH 2/5] Rename devcontainer --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2b794de3b5..6c79e2bcfb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "name": "TorchServe Dev Container", + "name": "TorchServe Dev Environment", "build": { "dockerfile": "../docker/Dockerfile", "context": "..", From 11ff3eb070e273db1bb30f690020c1871e0e3aff Mon Sep 17 00:00:00 2001 From: yhna Date: Sun, 13 Oct 2024 00:55:54 +0900 Subject: [PATCH 3/5] Minor --- .devcontainer/devcontainer.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6c79e2bcfb..4bd322f90e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -23,8 +23,5 @@ // "--gpus", "all", // Enable the docker container to access system resources "--ipc", "host" - ], - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - } + ] } From 5b7b8ef84c08febd6e5adf4d88669bdeeea53b11 Mon Sep 17 00:00:00 2001 From: yhna940 Date: Wed, 16 Oct 2024 10:17:58 +0900 Subject: [PATCH 4/5] Updatae docker readme --- docker/README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docker/README.md b/docker/README.md index beb0604e10..2b853a3ee1 100644 --- a/docker/README.md +++ b/docker/README.md @@ -304,6 +304,54 @@ docker run --rm --shm-size=1g \ --mount type=bind,source=/path/to/model/store,target=/tmp/models torchserve --model-store=/tmp/models ``` +# Development Environment with VS Code Dev Containers + +This section provides a guide on setting up a development environment for TorchServe using Visual Studio Code Dev Containers. + +## Setup Instructions + +1. **Install the Dev Containers Extension** + In Visual Studio Code, search for "Dev Containers" in the Extensions marketplace and install it. + + ![Dev Containers Extension Installation](https://github.com/user-attachments/assets/16e1fd10-b20e-4ef4-a16f-0f544d233ba6) + +2. **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. + + ![Reopen in Container](https://github.com/user-attachments/assets/31c3c090-2808-4e55-8d2e-89d4ab40649f) + +## Customizing the Development Environment + +To use a GPU-based container or make other modifications, update the `.devcontainer/devcontainer.json` file. Here’s an example configuration for a GPU-enabled environment: + +```json +{ + "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" + ] +} +``` + # Example showing serving model using Docker container [This](../examples/image_classifier/mnist/Docker.md) is an example showing serving MNIST model using Docker. From a10c54607add54b9c2778ca9fff3c9b6bcb01a2b Mon Sep 17 00:00:00 2001 From: yhna940 Date: Wed, 16 Oct 2024 10:24:53 +0900 Subject: [PATCH 5/5] Update contributing markdown --- CONTRIBUTING.md | 4 ++++ docker/README.md | 1 + 2 files changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a25e754761..e863abb319 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,6 +81,10 @@ Refer to the documentation [here](docs/torchserve_on_win_native.md). For information about the model archiver, see [detailed documentation](model-archiver/README.md). +### Using Visual Studio Code Dev Containers + +You can also set up a development environment for TorchServe using Visual Studio Code Dev Containers. This approach provides a fully-isolated, Docker-based environment that simplifies setup and ensures consistency across different development machines. Follow the guide in the [Development Environment with VS Code Dev Containers](docker/README.md#development-environment-with-vs-code-dev-containers) section of the Docker README for setup instructions and customization options. + ### What to Contribute? ### A good first issue diff --git a/docker/README.md b/docker/README.md index 2b853a3ee1..f22d2d8c41 100644 --- a/docker/README.md +++ b/docker/README.md @@ -12,6 +12,7 @@ TorchServe now enforces token authorization enabled and model API control disabl * [Create TorchServe docker image](#create-torchserve-docker-image) * [Create torch-model-archiver from container](#create-torch-model-archiver-from-container) * [Running TorchServe docker image in production](#running-torchserve-in-a-production-docker-environment) +* [Development Environment with VS Code Dev Containers](#development-environment-with-vs-code-dev-containers) # Prerequisites