|
1 | 1 | # Build Docker Images |
2 | 2 |
|
3 | | -This guide provides two methods for building Docker images: |
| 3 | +This guide explains how to build the NeMo RL Docker image. |
4 | 4 |
|
5 | | -* **release**: Contains everything from the hermetic image, plus the nemo-rl source code and pre-fetched virtual environments for isolated workers. |
6 | | -* **hermetic**: Includes the base image plus pre-fetched NeMo RL python packages in the `uv` cache. |
| 5 | +The **release** image is our recommended option as it provides the most complete environment. It includes the base image with pre-fetched NeMo RL python packages in the `uv` cache, plus the nemo-rl source code and pre-fetched virtual environments for isolated workers. This is the ideal choice for production deployments. |
7 | 6 |
|
8 | | -Use the: |
9 | | -* **release** (recommended): if you want to pre-fetch the NeMo RL [worker virtual environments](./design-docs/uv.md#worker-configuration) and copy in the project source code. |
10 | | -* **hermetic**: if you want to pre-fetch NeMo RL python packages into the `uv` cache to eliminate the initial overhead of program start. |
11 | | - |
12 | | -## Release Image |
13 | | - |
14 | | -The release image is our recommended option as it provides the most complete environment. It includes everything from the hermetic image, plus the nemo-rl source code and pre-fetched virtual environments for isolated workers. This is the ideal choice for production deployments. |
| 7 | +## Building the Release Image |
15 | 8 |
|
16 | 9 | ```sh |
17 | 10 | # Self-contained build (default: builds from main): |
18 | | -docker buildx build --target release -f docker/Dockerfile --tag <registry>/nemo-rl:latest --push . |
| 11 | +docker buildx build -f docker/Dockerfile \ |
| 12 | + --tag <registry>/nemo-rl:latest \ |
| 13 | + --push . |
19 | 14 |
|
20 | 15 | # Self-contained build (specific git ref): |
21 | | -docker buildx build --target release -f docker/Dockerfile --build-arg NRL_GIT_REF=r0.3.0 --tag <registry>/nemo-rl:r0.3.0 --push . |
| 16 | +docker buildx build -f docker/Dockerfile \ |
| 17 | + --build-arg NRL_GIT_REF=r0.3.0 \ |
| 18 | + --tag <registry>/nemo-rl:r0.3.0 \ |
| 19 | + --push . |
22 | 20 |
|
23 | 21 | # Self-contained build (remote NeMo RL source; no need for a local clone of NeMo RL): |
24 | | -docker buildx build --target release -f docker/Dockerfile --build-arg NRL_GIT_REF=r0.3.0 --tag <registry>/nemo-rl:r0.3.0 --push https://github.com/NVIDIA-NeMo/RL.git |
| 22 | +docker buildx build -f docker/Dockerfile \ |
| 23 | + --build-arg NRL_GIT_REF=r0.3.0 \ |
| 24 | + --tag <registry>/nemo-rl:r0.3.0 \ |
| 25 | + --push https://github.com/NVIDIA-NeMo/RL.git |
25 | 26 |
|
26 | 27 | # Local NeMo RL source override: |
27 | | -docker buildx build --target release --build-context nemo-rl=. -f docker/Dockerfile --tag <registry>/nemo-rl:latest --push . |
| 28 | +docker buildx build --build-context nemo-rl=. -f docker/Dockerfile \ |
| 29 | + --tag <registry>/nemo-rl:latest \ |
| 30 | + --push . |
28 | 31 | ``` |
29 | 32 |
|
30 | | -**Note:** The `--tag <registry>/nemo-rl:latest --push` flags are not necessary if you just want to build locally. |
| 33 | +> [!NOTE] |
| 34 | +> The `--tag <registry>/nemo-rl:latest --push` flags are not necessary if you just want to build locally. |
31 | 35 |
|
32 | | -## Hermetic Image |
| 36 | +## Skipping vLLM or SGLang Dependencies |
33 | 37 |
|
34 | | -The hermetic image includes all Python dependencies pre-downloaded in the `uv` cache, eliminating the initial overhead of downloading packages at runtime. This is useful when you need a more predictable environment or have limited network connectivity. |
| 38 | +If you don't need vLLM or SGLang support, you can skip building those dependencies to reduce build time and image size. Use the `SKIP_VLLM_BUILD` and/or `SKIP_SGLANG_BUILD` build arguments: |
35 | 39 |
|
36 | 40 | ```sh |
37 | | -# Self-contained build (default: builds from main): |
38 | | -docker buildx build --target hermetic -f docker/Dockerfile --tag <registry>/nemo-rl:latest --push . |
39 | | - |
40 | | -# Self-contained build (specific git ref): |
41 | | -docker buildx build --target hermetic -f docker/Dockerfile --build-arg NRL_GIT_REF=r0.3.0 --tag <registry>/nemo-rl:r0.3.0 --push . |
42 | | - |
43 | | -# Self-contained build (remote NeMo RL source; no need for a local clone of NeMo RL): |
44 | | -docker buildx build --target hermetic -f docker/Dockerfile --build-arg NRL_GIT_REF=r0.3.0 --tag <registry>/nemo-rl:r0.3.0 --push https://github.com/NVIDIA-NeMo/RL.git |
45 | | - |
46 | | -# Local NeMo RL source override: |
47 | | -docker buildx build --target hermetic --build-context nemo-rl=. -f docker/Dockerfile --tag <registry>/nemo-rl:latest --push . |
| 41 | +# Skip vLLM dependencies: |
| 42 | +docker buildx build -f docker/Dockerfile \ |
| 43 | + --build-arg SKIP_VLLM_BUILD=1 \ |
| 44 | + --tag <registry>/nemo-rl:latest \ |
| 45 | + . |
| 46 | + |
| 47 | +# Skip SGLang dependencies: |
| 48 | +docker buildx build -f docker/Dockerfile \ |
| 49 | + --build-arg SKIP_SGLANG_BUILD=1 \ |
| 50 | + --tag <registry>/nemo-rl:latest \ |
| 51 | + . |
| 52 | + |
| 53 | +# Skip both vLLM and SGLang dependencies: |
| 54 | +docker buildx build -f docker/Dockerfile \ |
| 55 | + --build-arg SKIP_VLLM_BUILD=1 \ |
| 56 | + --build-arg SKIP_SGLANG_BUILD=1 \ |
| 57 | + --tag <registry>/nemo-rl:latest \ |
| 58 | + . |
48 | 59 | ``` |
49 | 60 |
|
50 | | -**Note:** The `--tag <registry>/nemo-rl:latest --push` flags are not necessary if you just want to build locally. |
| 61 | +When these build arguments are set, the corresponding `uv sync --extra` commands are skipped, and the virtual environment prefetching will exclude actors that depend on those packages. |
| 62 | + |
| 63 | +> [!NOTE] |
| 64 | +> If you skip vLLM or SGLang during the build but later try to use those backends at runtime, the dependencies will be fetched and built on-demand. This may add significant setup time on first use. |
0 commit comments