This week I am going to install a gpu enabled docker image, first you have to figure out what type of gpu and version you are running. You can not run nvidia-docker on windows systems.

+—————————————————————————–+ | NVIDIA-SMI 441.12 Driver Version: 441.12 CUDA Version: 10.2 | |——————————-+———————-+———————-+ | GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 1060 WDDM | 00000000:01:00.0 On | N/A | | N/A 45C P8 3W / N/A | 143MiB / 6144MiB | 0% Default | +——————————-+———————-+———————-+

+—————————————————————————–+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1640 C+G Insufficient Permissions N/A | | 0 15968 C+G Insufficient Permissions N/A | +—————————————————————————–+

Visit: https://github.com/NVIDIA/nvidia-docker, and run the commands under the version of linux you are running.

I am using Ubuntu so these are the commands that I ran.

Add the package repositories

$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) $ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - $ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

$ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit $ sudo systemctl restart docker

After these have completed you can can use any of these commands depending on what you wish to accomplish.

Test nvidia-smi with the latest official CUDA image

$ docker run –gpus all nvidia/cuda:9.0-base nvidia-smi

Start a GPU enabled container on two GPUs

$ docker run –gpus 2 nvidia/cuda:9.0-base nvidia-smi

Starting a GPU enabled container on specific GPUs

$ docker run –gpus ‘“device=1,2”’ nvidia/cuda:9.0-base nvidia-smi $ docker run –gpus ‘“device=UUID-ABCDEF,1”’ nvidia/cuda:9.0-base nvidia-smi

Specifying a capability (graphics, compute, …) for my container

Note this is rarely if ever used this way

$ docker run –gpus all,capabilities=utility nvidia/cuda:9.0-base nvidia-smi

This will allow you to run a GPU accelerated docker containers.