I wanted to test the faceswap ML tool, and I hate now installing stuff with that many dependencies on my system.

I was pleased to see that it provides a docker image, but it needs a GPU passthrough which necessit to have nvidia-docker installed.

No package

The supported list

At the time of writing Buster is Debian testing and Nvidia doesn't provide a package for that release :

Fortunately their repos are well made and the hack was mainly about expanding their Makefile

Expanding the makefiles

nvidia-docker

The one that interests us is nvidia-docker.

Here's a diff of the Makefile, as you see it's pretty simple, just add the debianbuster command

diff --git a/Makefile b/Makefile
index a40edbf..14574de 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ DIST_DIR  := $(CURDIR)/dist
 .NOTPARALLEL:
 .PHONY: all

-all: ubuntu18.04 ubuntu16.04 ubuntu14.04 debian9 debian8 centos7 amzn2 amzn1
+all: ubuntu18.04 ubuntu16.04 ubuntu14.04 debianbuster debian9 debian8 centos7 amzn2 amzn1

 ubuntu18.04: $(addsuffix -ubuntu18.04, 18.09.0 18.06.1 18.06.0 18.03.1 17.12.1)

@@ -19,6 +19,8 @@ ubuntu16.04: $(addsuffix -ubuntu16.04, 18.09.0 18.06.1 18.06.0 18.03.1 18.03.0 1

 ubuntu14.04: $(addsuffix -ubuntu14.04, 18.06.1 18.06.0 18.03.1 18.03.0 17.12.1 17.09.1 17.06.2 17.03.2)

+debianbuster: $(addsuffix -debianbuster, 18.09.0)
+
 debian9: $(addsuffix -debian9, 18.09.0 18.06.1 18.06.0 18.03.1 18.03.0 17.12.1 17.12.0 17.09.1 17.09.0 17.06.2 17.03.2)

 debian8: $(addsuffix -debian8, 18.06.1 18.06.0 18.03.1 18.03.0 17.12.1 17.09.1 17.06.2)
@@ -164,6 +166,25 @@ amzn1: $(addsuffix -amzn1, 18.06.1.ce 18.03.1.ce 17.12.1.ce 17.09.1.ce 17.06.2.c
                         -t "nvidia/nvidia-docker2/ubuntu:14.04-docker18.06.0" -f Dockerfile.ubuntu .
        $(DOCKER) run --rm -v $(DIST_DIR)/ubuntu14.04:/dist:Z "nvidia/nvidia-docker2/ubuntu:14.04-docker18.06.0"

+
+%-debianbuster:
+       $(DOCKER) build --build-arg VERSION_ID="buster" \
+                        --build-arg RUNTIME_VERSION="$(RUNTIME_VERSION)+docker$*-1" \
+                        --build-arg DOCKER_VERSION="docker-ce (= $*~ce-0~debian)" \
+                        --build-arg PKG_VERS="$(VERSION)+docker$*" \
+                        --build-arg PKG_REV="$(PKG_REV)" \
+                        -t "nvidia/nvidia-docker2/debian:buster-docker$*" -f Dockerfile.debian .
+       $(DOCKER) run --rm -v $(DIST_DIR)/debianbuster:/dist:Z "nvidia/nvidia-docker2/debian:buster-docker$*"
+
+18.09.0-debianbuster:
+       $(DOCKER) build --build-arg VERSION_ID="buster" \
+                        --build-arg RUNTIME_VERSION="$(RUNTIME_VERSION)+docker18.09.0-1" \
+                        --build-arg DOCKER_VERSION="docker-ce (= 5:18.09.0~3-0~debian-buster)" \
+                        --build-arg PKG_VERS="$(VERSION)+docker18.09.0" \
+                        --build-arg PKG_REV="$(PKG_REV)" \
+                        -t "nvidia/nvidia-docker2/debian:buster-docker18.09.0" -f Dockerfile.debian .
+       $(DOCKER) run --rm -v $(DIST_DIR)/debianbuster:/dist:Z "nvidia/nvidia-docker2/debian:buster-docker18.09.0"
+
 %-debian9:
        $(DOCKER) build --build-arg VERSION_ID="9" \
                         --build-arg RUNTIME_VERSION="$(RUNTIME_VERSION)+docker$*-1" \

Then we build all that with a make debianbuster and install that with sudo dpkg -i dist/debianbuster/nvidia-docker2_2.0.3+docker18.09.0-1_all.deb

Now we could be all set, unfortunatly there is still a bug in libnvidia-container which hasn't been packaged as well.

Those are issues #876 and #854 which are fixed in that libnvidia-container commit

libnvidia-container

Here it's just about cloning the repo and do a make docker-debian:buster, no other changes !

Then install the lib and the tool (needed for later) with sudo dpkg -i dist/debianbuster/libnvidia-container1_1.0.0-1_amd64.deb and sudo dpkg -i dist/debianbuster/libnvidia-container-tools_1.0.0-1_amd64.deb

nvidia-container-runtime

Now for nvidia-docker to run properly it needs the nvidia-container-runtime, which again needs to be compiled cloning the repo and and making the below changes:

It boils down as above to add buster to the Makefile, here we need it added in the main Makefile and in the hook and runtime subdirectories:

diff --git a/Makefile b/Makefile
index 7bc5b41..4034264 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@

 .PHONY: all

-all: ubuntu18.04 ubuntu16.04 ubuntu14.04 debian9 debian8 centos7 amzn2 amzn1
+all: ubuntu18.04 ubuntu16.04 ubuntu14.04 debianbuster debian9 debian8 centos7 amzn2 amzn1

 # Build all packages for a specific distribution.
 ubuntu18.04: runtime-ubuntu18.04 hook-ubuntu18.04
@@ -11,6 +11,8 @@ ubuntu16.04: runtime-ubuntu16.04 hook-ubuntu16.04

 ubuntu14.04: runtime-ubuntu14.04 hook-ubuntu14.04

+debianbuster: runtime-debianbuster hook-debianbuster
+
 debian9: runtime-debian9 hook-debian9

 debian8: runtime-debian8 hook-debian8
@@ -40,6 +42,9 @@ runtime-%: base-%
 %-runtime-ubuntu14.04: base-ubuntu14.04
        make -C $(CURDIR)/runtime $*-ubuntu14.04

+%-runtime-debianbuster: base-debianbuster
+       make -C $(CURDIR)/runtime $*-debianbuster
+
 %-runtime-debian9: base-debian9
        make -C $(CURDIR)/runtime $*-debian9

diff --git a/hook/Makefile b/hook/Makefile
index 484efe3..f97b51f 100644
--- a/hook/Makefile
+++ b/hook/Makefile
@@ -9,7 +9,7 @@ DIST_DIR  := $(CURDIR)/../dist
 .NOTPARALLEL:
 .PHONY: all

-all: ubuntu18.04 ubuntu16.04 ubuntu14.04 debian9 debian8 centos7 amzn2 amzn1
+all: ubuntu18.04 ubuntu16.04 ubuntu14.04 debianbuster debian9 debian8 centos7 amzn2 amzn1

 ubuntu%: $(CURDIR)/Dockerfile.ubuntu
        $(DOCKER) build --build-arg VERSION_ID="$*" \

diff --git a/runtime/Makefile b/runtime/Makefile
index 6ed46d6..33c7667 100644
--- a/runtime/Makefile
+++ b/runtime/Makefile
@@ -10,7 +10,7 @@ DIST_DIR  := $(CURDIR)/../dist
 .NOTPARALLEL:
 .PHONY: all


-all: ubuntu18.04 ubuntu16.04 ubuntu14.04 debian9 debian8 centos7 amzn2 amzn1
+all: ubuntu18.04 ubuntu16.04 ubuntu14.04 debianbuster debian9 debian8 centos7 amzn2 amzn1

 ubuntu18.04: $(addsuffix -ubuntu18.04, 18.09.0 18.06.1 18.06.0 18.03.1 17.12.1)

@@ -18,6 +18,8 @@ ubuntu16.04: $(addsuffix -ubuntu16.04, 18.09.0 18.06.1 18.06.0 18.03.1 18.03.0 1

 ubuntu14.04: $(addsuffix -ubuntu14.04, 18.06.1 18.06.0 18.03.1 18.03.0 17.12.1 17.09.1 17.06.2 17.03.2)

+debianbuster: $(addsuffix -debianbuster, 18.09.0)
+
 debian9: $(addsuffix -debian9, 18.09.0 18.06.1 18.06.0 18.03.1 18.03.0 17.12.1 17.12.0 17.09.1 17.09.0 17.06.2 17.03.2)

 debian8: $(addsuffix -debian8, 18.06.1 18.06.0 18.03.1 18.03.0 17.12.1 17.09.1 17.06.2)
@@ -91,6 +93,16 @@ amzn1: $(addsuffix -amzn1, 18.06.1 18.03.1 17.12.1 17.09.1 17.06.2 17.03.2)
                         -t "nvidia/runtime/ubuntu:14.04-docker$*" -f Dockerfile.ubuntu .
        $(DOCKER) run --rm -v $(DIST_DIR)/ubuntu14.04:/dist:Z "nvidia/runtime/ubuntu:14.04-docker$*"

+
+%-debianbuster:
+       runc="$(shell $(MAKE) -s $@-runc)" && \
+       $(DOCKER) build --build-arg VERSION_ID="buster" \
+                        --build-arg RUNC_COMMIT="$${runc}" \
+                        --build-arg PKG_VERS="$(VERSION)+docker$*" \
+                        --build-arg PKG_REV="$(PKG_REV)" \
+                        -t "nvidia/runtime/debian:buster-docker$*" -f Dockerfile.debian .
+       $(DOCKER) run --rm -v $(DIST_DIR)/debianbuster:/dist:Z "nvidia/runtime/debian:buster-docker$*"
+
 %-debian9:
        runc="$(shell $(MAKE) -s $@-runc)" && \
        $(DOCKER) build --build-arg VERSION_ID="9" \

And as buster doesn't contain backports repo I was gross and changed the Dockerfile.debian that way, one could make it more generic for sure

diff --git a/base/Dockerfile.debian b/base/Dockerfile.debian
index 220cb6e..fc83e3c 100644
--- a/base/Dockerfile.debian
+++ b/base/Dockerfile.debian
@@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
         lsb-release && \
     rm -rf /var/lib/apt/lists/*

-RUN echo "deb http://ftp.debian.org/debian $(lsb_release -cs)-backports main" > /etc/apt/sources.list.d/backports.list
+#RUN echo "deb http://ftp.debian.org/debian $(lsb_release -cs)-backports main" > /etc/apt/sources.list.d/backports.list

 ARG GOLANG_VERSION=0.0.0
 RUN set -eux; \
 
diff --git a/runtime/Dockerfile.debian b/runtime/Dockerfile.debian
index 929eff1..e1cdf2c 100644
--- a/runtime/Dockerfile.debian
+++ b/runtime/Dockerfile.debian
@@ -3,7 +3,7 @@ FROM nvidia/base/debian:${VERSION_ID}

 # runc dependencies
 RUN apt-get update && \
-    apt-get install -t "$(lsb_release -cs)-backports" -y \
+    apt-get install -t "$(lsb_release -cs)" -y \
         libseccomp-dev && \
     apt-get install -y \
         pkg-config \

Then make debianbuster and install hook and runtime with sudo dpkg -i dist/debianbuster/nvidia-container-runtime_2.0.0+docker18.09.0-1_amd64.deb and sudo dpkg -i dist/debianbuster/nvidia-container-runtime-hook_1.4.0-1_amd64.deb

And done !

Conclusion, does it work ?

Finally as instructed in the nvidia-docker repo kill the docker daemon and run a

➜  ~ docker run  --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi
Fri Jan  4 09:43:14 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.87                 Driver Version: 390.87                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:02:00.0  On |                  N/A |
| 27%   29C    P8     6W / 180W |    132MiB /  8118MiB |      1%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

Success