Search code examples
dockerdocker-composetensorflownvidia-docker

How do I specify nvidia runtime from docker-compose.yml?


I am able to run a tensorflow container w/ access to the GPU from the command line w/ the following command

$ sudo docker run --runtime=nvidia --rm gcr.io/tensorflow/tensorflow:latest-gpu

I would like to be able to run this container from docker-compose. Is it possible to specify the --runtime flag from docker-compose.yml?


Solution

  • You should edit /etc/docker/daemon.json, adding the first level key "default-runtime": "nvidia", restart docker daemon (ex. "sudo service docker restart") and then all containers on that host will run with nvidia runtime.

    More info on daemon.json here