Installing Docker on a GPU Machine

Step-by-step Instruction for compiling Docker on a GPU Machine

Install Docker from a package

1. Go to https://download.docker.com/linux/debian/dists/.

2. Select your Debian version in the list.

3. Go to pool/stable/ and select the applicable architecture (amd64, armhf, arm64, or s390x).

4. Download the following deb files for the Docker Engine, CLI, containerd, and Docker Compose packages:

  - containerd.io_<version>_<arch>.deb
  - docker-ce_<version>_<arch>.deb
  - docker-ce-cli_<version>_<arch>.deb
  - docker-buildx-plugin_<version>_<arch>.deb
  - docker-compose-plugin_<version>_<arch>.deb

5. Install the .deb packages. Update the paths in the following example to where you downloaded the Docker packages.

sudo dpkg -i ./containerd.io_<version>_<arch>.deb
sudo dpkg -i ./docker-ce_<version>_<arch>.deb
...

6. Verify that the installation is successful by running the hello-world image

 sudo service docker start
 sudo docker run hello-world

Installing the NVIDIA Container Toolkit

1. Configure the production repository:

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
  && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

2. Update the packages list from the repository:

sudo apt-get update

3. Install the NVIDIA Container Toolkit packages:

export NVIDIA_CONTAINER_TOOLKIT_VERSION=1.17.8-1
  sudo apt-get install -y \
      nvidia-container-toolkit=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      nvidia-container-toolkit-base=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      libnvidia-container-tools=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
      libnvidia-container1=${NVIDIA_CONTAINER_TOOLKIT_VERSION}

Configuring Docker

1. Create the docker group (if it doesn’t exist)

Check if a docker group exist using

getent group docker

If it does not exist, then create a new group

sudo groupadd docker

2. Add your user to the group

sudo usermod -aG docker nam

3. Configure the container runtime by using the nvidia-ctk command:

sudo nvidia-ctk runtime configure --runtime=docker

The nvidia-ctk command modifies the /etc/docker/daemon.json file on the host. The file is updated so that Docker can use the NVIDIA Container Runtime.

4. Restart the Docker daemon:

sudo systemctl restart docker

5. Run a sample CUDA container:

sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi

How to run

docker run -it --rm \
  --gpus all  \
  --runtime=nvidia \
  registry.bohrium.dp.tech/dptech/dp/native/prod-759944/deepmd:dEdN /bin/bash