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
?
Using the NVIDIA Container Runtime for Docker Use docker run and specify runtime=nvidia . Use nvidia-docker run . The new package provides backward compatibility, so you can still run GPU-accelerated containers by using this command, and the new runtime will be used. Use docker run with nvidia as the default runtime.
NVIDIA Container Runtime is a GPU aware container runtime, compatible with the Open Containers Initiative (OCI) specification used by Docker, CRI-O, and other popular container technologies. It simplifies the process of building and deploying containerized GPU-accelerated applications to desktop, cloud or data centers.
Simply edit ~/. config/docker/daemon. json , and add crun to the list of runtimes, then set crun to be the default runtime.
To use your GPU with Docker, begin by adding the NVIDIA Container Toolkit to your host. This integrates into Docker Engine to automatically configure your containers for GPU support. The Container Toolkit should now be operational. You're ready to start a test container.
Currently (Aug 2018), NVIDIA container runtime for Docker (nvidia-docker2) supports Docker Compose.
Yes, use Compose format 2.3 and add runtime: nvidia to your GPU service. Docker Compose must be version 1.19.0 or higher.
Example docker-compose.yml
:
version: '2.3' services: nvsmi: image: ubuntu:16.04 runtime: nvidia environment: - NVIDIA_VISIBLE_DEVICES=all command: nvidia-smi
More example from NVIDIA blog uses Docker Compose to show how to launch multiple GPU containers with the NVIDIA Container Runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With