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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "TorchServe Dev Environment",
"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"
]
}
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 49 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -304,6 +305,54 @@ docker run --rm --shm-size=1g \
--mount type=bind,source=/path/to/model/store,target=/tmp/models <container> 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.