Using GPU in Docker container
I need to access GPU within my docker container, so I followed the Docker documentation, added the following lines to the docker-compose.yml
file:
After running docker-compose up
command, I got the following error:
Error response from daemon: could not select device driver "nvidia" with capabilities: [[gpu]]
Although I have already installed NVIDIA drivers on my host, it looks like the GPU is not recognized in Docker container.
After reading this, I realized that I also need to install the NVIDIA Container Toolkit.
- Install the nvidia-docker2 package:
- Then restart the Docker daemon: