Thursday, March 11, 2021

How to use NVIDIA GPUs in docker container


This is a quick note on how to use NVIDIA GPUs in docker container.


Ubuntu 18.04

Docker 20.10.5


The key is to install NVIDIA Container Toolkit that is why this note is quick:)

1. Install Docker on host machine where NVIDIA driver is already installed.

2. Install NVIDIA Container Toolkit on host machine

3. Test

sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi

Or only expose the first GPU(with device=0) instead of all GPU to docker container:

docker run --rm --gpus device=0 nvidia/cuda:11.0-base nvidia-smi

No comments:

Post a Comment

Popular Posts