Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b7a0690

Browse files
authoredApr 16, 2024
Add vscode configurations to make development easier (#352)
* Add vscode configurations to make development easier * Review comment * Fix merge conflict * Fix permission * Update dockerfile * Fix username * Review comments * Add link * Review edit
1 parent ad4a440 commit b7a0690

File tree

5 files changed

+171
-1
lines changed

5 files changed

+171
-1
lines changed
 

‎.devcontainer/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
FROM nvcr.io/nvidia/tritonserver:24.03-py3
28+
29+
ARG USERNAME=triton-server
30+
31+
RUN apt-get update \
32+
&& apt-get install -y sudo
33+
34+
RUN pip3 install transformers torch
35+
36+
# Create the user
37+
RUN apt-get update \
38+
&& apt-get install -y sudo \
39+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
40+
&& chmod 0440 /etc/sudoers.d/$USERNAME
41+
42+
RUN pip3 install pre-commit ipdb
43+
44+
RUN mkhomedir_helper triton-server
45+
46+
RUN apt-get install -y cmake rapidjson-dev
47+
48+
USER ${USERNAME}

‎.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "Python Backend",
3+
4+
"build": {
5+
"dockerfile": "Dockerfile"
6+
},
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"ms-python.vscode-pylance",
11+
"ms-python.python",
12+
"ms-vscode.cpptools-extension-pack",
13+
"ms-vscode.cmake-tools",
14+
"github.vscode-pull-request-github"
15+
]
16+
}
17+
},
18+
"postCreateCommand": "sudo chown -R triton-server:triton-server ~/.cache",
19+
20+
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", "--gpus=all", "--shm-size=2g", "--ulimit", "stack=67108864" ],
21+
"mounts": [
22+
"source=${localEnv:HOME}/.ssh,target=/home/triton-server/.ssh,type=bind,consistency=cached",
23+
"source=${localEnv:HOME}/.cache/huggingface,target=/home/triton-server/.cache/huggingface,type=bind,consistency=cached"
24+
],
25+
"remoteUser": "triton-server"
26+
}

‎.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/build
2-
/.vscode
32
*.so
43
builddir
54

‎.vscode/tasks.json

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Configure",
6+
"type": "shell",
7+
"command": "cmake",
8+
"args": [
9+
"-DCMAKE_INSTALL_PREFIX:STRING=/opt/tritonserver/",
10+
"-DTRITON_COMMON_REPO_TAG:STRING=main",
11+
"-DTRITON_BACKEND_REPO_TAG:STRING=main",
12+
"-DTRITON_CORE_REPO_TAG:STRING=main",
13+
"-DTRITON_ENABLE_GPU:STRING=ON",
14+
"-DTRITON_ENABLE_NVTX:STRING=ON",
15+
"-DCMAKE_INSTALL_PREFIX:STRING=${workspaceFolder}/build/install",
16+
"-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE",
17+
"-DCMAKE_BUILD_TYPE:STRING=Debug",
18+
"-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc",
19+
"-DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++",
20+
"-S${workspaceFolder}",
21+
"-B${workspaceFolder}/build",
22+
"-G",
23+
"Unix Makefiles"
24+
],
25+
"problemMatcher": []
26+
},
27+
{
28+
"label": "Build",
29+
"type": "shell",
30+
"command": "cmake",
31+
"args": [
32+
"--build",
33+
"/${workspaceFolder}/build",
34+
"--config",
35+
"Debug",
36+
"--target",
37+
"all",
38+
"-j",
39+
"18",
40+
"--"
41+
]
42+
},
43+
{
44+
"label": "Install",
45+
"type": "shell",
46+
"command": "cmake",
47+
"args": [
48+
"--build",
49+
"${workspaceFolder}/build",
50+
"--config",
51+
"Debug",
52+
"--target",
53+
"install",
54+
"-j",
55+
"18",
56+
"--"
57+
]
58+
},
59+
{
60+
"label": "Move",
61+
"type": "shell",
62+
"command": "sudo",
63+
"args": [
64+
"cp",
65+
"-r",
66+
"${workspaceFolder}/build/install/backends/python/*",
67+
"/opt/tritonserver/backends/python"
68+
]
69+
},
70+
{
71+
"label": "Build Python Backend",
72+
"dependsOrder": "sequence",
73+
"dependsOn": [
74+
"Configure",
75+
"Build",
76+
"Install",
77+
"Move"
78+
],
79+
"group": {
80+
"kind": "build",
81+
"isDefault": true
82+
}
83+
}
84+
]
85+
}

‎README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ any C++ code.
9090
- [Custom Metrics](#custom-metrics-1)
9191
- [Running with Inferentia](#running-with-inferentia)
9292
- [Logging](#logging)
93+
- [Development with VSCode](#development-with-vscode)
9394
- [Reporting problems, asking questions](#reporting-problems-asking-questions)
9495

9596
## Quick Start
@@ -1825,6 +1826,17 @@ def initialize(self, args):
18251826
# Should print {'custom_key': {'string_value': 'custom_value'}}
18261827
```
18271828

1829+
# Development with VSCode
1830+
1831+
The repository includes a `.devcontainer` folder that contains a `Dockerfile`
1832+
and `devcontainer.json` file to help you develop the Python backend
1833+
using
1834+
[Visual Studio Code](https://code.visualstudio.com/docs/devcontainers/containers).
1835+
1836+
In order to build the backend, you can execute the "Build Python Backend" task in the
1837+
[VSCode tasks](https://code.visualstudio.com/docs/editor/tasks). This will build
1838+
the Python backend and install the artifacts in
1839+
`/opt/tritonserver/backends/python`.
18281840

18291841

18301842
# Reporting problems, asking questions

0 commit comments

Comments
 (0)