NVIDIA DGX H100 User Guide
4.7.2. Using the NVIDIA Container Runtime for Docker
If you need to use nvidia-docker2, install it using sudo apt install nvidia-docker2, then run:
sudo systemctl restart docker
The DGX OS also includes the NVIDIA Container Runtime for Docker (nvidia- docker2) which lets you
run GPU-accelerated containers in one of the following ways:
▶ Use docker run and specify runtime=nvidia.
docker run --runtime=nvidia ...
▶ Use nvidia-docker run.
nvidia-docker run ...
The nvidia-docker2 package provides backward compatibility with the previous nvidia-docker package,
so you can run GPU-accelerated containers using this command and the new runtime will be used.
▶ Use docker run with nvidia as the default runtime.
You can set nvidia as the default runtime, for example, by adding the following line to the ∕
etc∕docker∕daemon.json conguration le as the rst entry.
"default-runtime": "nvidia",
Here is an example of how the added line appears in the JSON le. Do not remove any pre-existing
content when making this change.
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "∕usr∕bin∕nvidia-container-runtime",
"args": []
}
}
}
You can then use docker run to run GPU-accelerated containers.
docker run ...
Caution: If you build Docker images while nvidia is set as the default runtime, make sure the
build scripts executed by the Dockerle specify the GPU architectures that the container will need.
Failure to do so might result in the container being optimized only for the GPU architecture on
which it was built. Instructions for specifying the GPU architecture depend on the application and
are beyond the scope of this document. Consult the specic application build process.
For more information, refer to the NVIDIA DGX OS 6 User Guide.
4.7. Running NGC Containers with GPU Support 31