You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developer/development_guide_using_docker.md
+64-8
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
1
# Development Guide Using Docker
2
2
3
-
## Setup VSCode
3
+
## Setup VSCode on a Remote Host
4
+
(Optional - you can skip this step if you plan to run sglang dev container locally)
4
5
5
-
Download `code` from `Https://code.visualstudio.com/docs/?dv=linux64cli`
6
+
1. In the remote host, download `code` from [Https://code.visualstudio.com/docs/?dv=linux64cli](https://code.visualstudio.com/download) and run `code tunnel` in a shell.
@@ -12,29 +14,83 @@ tar xf vscode_cli_alpine_x64_cli.tar.gz
12
14
./code tunnel
13
15
```
14
16
17
+
2. In your local machine, press F1 in VSCode and choose "Remote Tunnels: Connect to Tunnel".
18
+
15
19
## Setup Docker Container
16
20
21
+
### Option 1. Use the default dev container automatically from VSCode
22
+
There is a `.devcontainer` folder in the sglang repository root folder to allow VSCode to automatically start up within dev container. You can read more about this VSCode extension in VSCode official document [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers).
(*Figure 1: Diagram from VSCode official documentation [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers).*)
25
+
26
+
To enable this, you only need to:
27
+
1. Start Visual Studio Code and install [VSCode dev container extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
28
+
2. Press F1, type and choose "Dev Container: Open Folder in Container.
29
+
3. Input the `sglang` local repo path in your machine and press enter.
30
+
31
+
The first time you open it in dev container might take longer due to docker pull and build. Once it's successful, you should set on your status bar at the bottom left displaying that you are in a dev container:
Now when you run `sglang.launch_server` in the VSCode terminal or start debugging using F5, sglang server will be started in the dev container with all your local changes applied automatically:
### Option 2. Start up containers manually (advanced)
41
+
17
42
The following startup command is an example for internal development by the SGLang team. You can **modify or add directory mappings as needed**, especially for model weight downloads, to prevent repeated downloads by different Docker containers.
18
43
19
44
❗️ **Note on RDMA**
20
45
21
46
1. `--network host` and `--privileged` are required by RDMA. If you don't need RDMA, you can remove them but keeping them there does not harm. Thus, we enable these two flags by default in the commands below.
22
47
2. You may need to set `NCCL_IB_GID_INDEX` if you are using RoCE, for example: `export NCCL_IB_GID_INDEX=3`.
23
48
24
-
### H100
25
-
26
49
```bash
27
50
# Change the name to yours
51
+
docker run -itd --shm-size 32g --gpus all -v <volumes-to-mount> --ipc=host --network=host --privileged --name sglang_dev lmsysorg/sglang:dev /bin/zsh
52
+
docker exec -it sglang_dev /bin/zsh
53
+
```
54
+
Some useful volumes to mount are:
55
+
1.**Huggingface model cache**: mounting model cache can avoid re-download everytime docker restarts. Default location on Linux is `~/.cache/huggingface/`.
56
+
2.**SGLang repository**: code changes in the SGLang local repository will be automatically synced to the .devcontainer.
57
+
58
+
Example 1: Monting local cache folder `/opt/dlami/nvme/.cache` but not the SGLang repo. Use this when you prefer to manually transfer local code changes to the devcontainer.
59
+
```bash
28
60
docker run -itd --shm-size 32g --gpus all -v /opt/dlami/nvme/.cache:/root/.cache --ipc=host --network=host --privileged --name sglang_zhyncs lmsysorg/sglang:dev /bin/zsh
29
61
docker exec -it sglang_zhyncs /bin/zsh
30
62
```
31
-
32
-
### H200
33
-
63
+
Example 2: Mounting both HuggingFace cache and local SGLang repo. Local code changes are automatically synced to the devcontainer as the SGLang is installed in editable mode in the dev image.
34
64
```bash
35
-
docker run -itd --shm-size 32g --gpus all -v /mnt/co-research/shared-models:/root/.cache/huggingface --ipc=host --network=host --privileged --name sglang_zhyncs lmsysorg/sglang:dev /bin/zsh
65
+
docker run -itd --shm-size 32g --gpus all -v $HOME/.cache/huggingface/:/root/.cache/huggingface -v $HOME/src/sglang:/sgl-workspace/sglang --ipc=host --network=host --privileged --name sglang_zhyncs lmsysorg/sglang:dev /bin/zsh
36
66
docker exec -it sglang_zhyncs /bin/zsh
37
67
```
68
+
## Debug SGLang with VSCode Debugger
69
+
1. (Create if not exist) open `launch.json` in VSCode.
70
+
2. Add the following config and save. Please note that you can edit the script as needed to apply different parameters or debug a different program (e.g. benchmark script).
71
+
```JSON
72
+
{
73
+
"version": "0.2.0",
74
+
"configurations": [
75
+
{
76
+
"name": "Python Debugger: launch_server",
77
+
"type": "debugpy",
78
+
"request": "launch",
79
+
"module": "sglang.launch_server",
80
+
"console": "integratedTerminal",
81
+
"args": [
82
+
"--model-path", "meta-llama/Llama-3.2-1B",
83
+
"--host", "0.0.0.0",
84
+
"--port", "30000",
85
+
"--trust-remote-code",
86
+
],
87
+
"justMyCode": false
88
+
}
89
+
]
90
+
}
91
+
```
92
+
93
+
3. Press "F5" to start. VSCode debugger will ensure that the program will pause at the breakpoints even if the program is running at remote SSH/Tunnel host + dev container.
0 commit comments