Skip to content

Dear Internet Explorer user: Your browser is no longer supported

Please switch to a modern browser such as Microsoft Edge, Mozilla Firefox or Google Chrome to view this website's content.

Installing NVIDIA CUDA in a Docker container

In order to utilise NVIDIA CUDA within a Docker Container, it needs to be enabled on the device hosting the container.

CUDA, or Compute Unified Device Architecture, is a parallel computing platform and programming model developed by NVIDIA that allows developers to use NVIDIA GPUs for general-purpose processing. Even if a device has CUDA installed, it will not work within a Docker container unless it is enabled.

To enable CUDA within a Docker container, complete the following steps:

Step 1

Install Docker on your system:

sudo apt install docker.io

Step 2

Verify the Docker installation:

docker --version

Step 3

Install the NVIDIA Container Toolkit:

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey

Step 4

Update the package database

sudo apt-get update

Step 5

Install the toolkit:

sudo apt-get install -y nvidia-container-toolkit

Step 6

Configure Docker to use the NVIDIA runtime:

sudo nvidia-ctk runtime configure --runtime=docker

Step 7

Restart Docker:

sudo systemctl restart docker

Step 8

Test that the new setup works via the --gpus all flag. For instance:

docker run --gpus all nvidia/cuda:12.0-base nvidia-smi

   

Comments

No comments have yet been submitted. Be the first!

Have Your Say

The following HTML is permitted:
<a href="" title=""> <b> <blockquote cite=""> <code> <em> <i> <q cite=""> <strike> <strong>

Comments will be published subject to the Editorial Policy.