nvidia-docker icon indicating copy to clipboard operation
nvidia-docker copied to clipboard

Using docker-in-docker fails with nvidia-docker in gitlab CI-pipeline

Open ultimanet opened this issue 9 years ago • 4 comments

We try to use nvidia-docker in our gitlab continuous integration pipeline. Thereby the release step using docker-in-docker fails.

We couldn't figure out, how to directly tell gitlab to use nvidia-docker instead of docker. Hence, we renamed /usr/bin/docker to /usr/bin/docker_pure and /usr/bin/nvidia-docker to /usr/bin/docker. Additionally we added NV_DOCKER="/usr/bin/docker_pure" to /etc/environment.

With this, our regular CI steps work perfectly fine but the release step fails:

$ docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?). Using system default: https://index.docker.io/v1/ Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ERROR: Job failed: exit code 1

We had this error before when docker was started without the -privileged flag. But using this method here, I was able to check, that the container in fact is privileged: https://stackoverflow.com/questions/32144575/how-to-know-if-a-docker-container-is-running-in-privileged-mode

ultimanet avatar May 22 '17 22:05 ultimanet

If possible, I suggest to simply use the REST API of nvidia-docker-plugin to get the CLI arguments to use in your command:

$ curl -s http://localhost:3476/docker/cli                                                                                                                                                                                                                              
--volume-driver=nvidia-docker --volume=nvidia_driver_375.51:/usr/local/nvidia:ro --device=/dev/nvidiactl --device=/dev/nvidia-uvm --device=/dev/nvidia-uvm-tools --device=/dev/nvidia1 --device=/dev/nvidia0

flx42 avatar May 22 '17 23:05 flx42

Thanks for the quick reply! Unfortunately, gitlab-ci doesn't allow to pass custom flags to docker at the moment: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/903

ultimanet avatar May 22 '17 23:05 ultimanet

What about gitlab-runner register --docker-devices [...] --docker-volumes [...] --docker-volumes-driver [...]?

flx42 avatar May 23 '17 00:05 flx42

Fixed it: Installing nvidia-docker somehow caused the overlay drive to get kicked out of the kernel modules. sudo modprobe overlay fixed it.

But anyway: Many thanks for the hint! With devices, volumes and volume-drive I can now set up different kinds (cuda and non-cuda) of runners in the config.toml and can avoid those nasty renaming hacks.

ultimanet avatar May 23 '17 01:05 ultimanet