Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use nvidia-docker from docker-compose

I would like to run 2 docker images with docker-compose.

one image should run with nvidia-docker and the other with docker.

I've seen this post use nvidia-docker-compose launch a container, but exited soon but this is not working for me(not even running only one image)...

any idea would be great.

like image 674
boaz Avatar asked Apr 12 '17 11:04

boaz


1 Answers

UPDATE : please check nvidia-docker 2 and its support of docker-compose first https://github.com/NVIDIA/nvidia-docker/wiki/Frequently-Asked-Questions#do-you-support-docker-compose

(I'd first suggest adding the nvidia-docker tag).

If you look at the nvidia-docker-compose code here it only generates a specific docker-file for docker-compose after a query of the nvidia configuration on localhost:3476.

You can also make by hand this docker-compose file as they turn out to be quite simple, follow this example, replace 375.66 with your nvidia driver version and put as many /dev/nvidia[n] lines as you have graphic cards (did not try to put services on separate GPUs but go for it !):

services:
  exampleservice0:
    devices:
    - /dev/nvidia0
    - /dev/nvidia1
    - /dev/nvidiactl
    - /dev/nvidia-uvm
    - /dev/nvidia-uvm-tools
    environment:
    - EXAMPLE_ENV_VARIABLE=example
    image: company/image
    volumes:
    - ./disk:/disk
    - nvidia_driver_375.66:/usr/local/nvidia:ro
version: '2'
volumes:
  media: null
  nvidia_driver_375.66:
    external: true

Then just run this hand-made docker-compose file with a classic docker-compose command.

Maybe you can then compose with non nvidia dockers by skipping the nvidia specific stuff in the other services.

like image 85
florentbuisson Avatar answered Oct 06 '22 10:10

florentbuisson