Skip to content

Latest commit

 

History

History
95 lines (71 loc) · 3.37 KB

File metadata and controls

95 lines (71 loc) · 3.37 KB

Build Docker Images

This guide explains how to build the NeMo RL Docker image.

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.

Building the Release Image

# Self-contained build (default: builds from main):
docker buildx build -f docker/Dockerfile \
    --tag <registry>/nemo-rl:latest \
    --push .

# Self-contained build (specific git ref):
docker buildx build -f docker/Dockerfile \
    --build-arg NRL_GIT_REF=r0.6.0 \
    --tag <registry>/nemo-rl:r0.6.0 \
    --push .

# Self-contained build (remote NeMo RL source; no need for a local clone of NeMo RL):
docker buildx build -f docker/Dockerfile \
    --build-arg NRL_GIT_REF=r0.6.0 \
    --tag <registry>/nemo-rl:r0.6.0 \
    --push https://github.com/NVIDIA-NeMo/RL.git

# Local NeMo RL source override:
docker buildx build --build-context nemo-rl=. -f docker/Dockerfile \
    --tag <registry>/nemo-rl:latest \
    --push .

Note

The --tag <registry>/nemo-rl:latest --push flags are not necessary if you just want to build locally.

Skipping vLLM or SGLang Dependencies

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:

# Skip vLLM dependencies:
docker buildx build -f docker/Dockerfile \
    --build-arg SKIP_VLLM_BUILD=1 \
    --tag <registry>/nemo-rl:latest \
    .

# Skip SGLang dependencies:
docker buildx build -f docker/Dockerfile \
    --build-arg SKIP_SGLANG_BUILD=1 \
    --tag <registry>/nemo-rl:latest \
    .

# Skip both vLLM and SGLang dependencies:
docker buildx build -f docker/Dockerfile \
    --build-arg SKIP_VLLM_BUILD=1 \
    --build-arg SKIP_SGLANG_BUILD=1 \
    --tag <registry>/nemo-rl:latest \
    .

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.

Note

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.

Custom Setup Commands

By default, the Docker image installs apptainer (with a singularity symlink) via a pluggable custom-setup build stage. The default script is docker/install_apptainer.sh. You can override or skip this step at build time.

Override with a custom script

Create a directory containing your setup script(s), then pass it as a build context along with the script filename:

# my-setup-dir/my_script.sh
#!/bin/bash
set -euo pipefail
apt-get update && apt-get install -y my-custom-package
apt-get clean && rm -rf /var/lib/apt/lists/*
docker buildx build \
  --build-context custom-setup=my-setup-dir/ \
  --build-arg CUSTOM_SETUP_FNAME=my_script.sh \
  -f docker/Dockerfile --tag <registry>/nemo-rl:latest .

Skip custom setup entirely

To build without any custom setup commands, set CUSTOM_SETUP_FNAME to empty:

docker buildx build --build-arg CUSTOM_SETUP_FNAME= -f docker/Dockerfile --tag <registry>/nemo-rl:latest .