Trouble building Docker container with CuArrays

I’m trying to run my Docker container containing benchmarks of my Julia code that uses Flux/CuArrays but I’m unable to even build it, even on my VM with CUDA toolkit installed:

Error: Error building CUDAdrv:
Could not find CUDA driver library

The strange thing is that if I edit my Dockerfile below, omitting adding CuArrays then I can build it, run it interactively (sudo docker run --runtime=nvidia -it mydockerimage /bin/bash) and then do 'using Pkg; Pkg.add("CuArrays")' which works and I can then run my julia code. Can anyone see why the build doesn’t work?

FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
RUN apt-get update \ && apt-get install -y wget \ && rm -rf /var/lib/apt/lists/*
RUN apt-get update
RUN apt-get -y install curl
RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.0-linux-x86_64.tar.gz
RUN tar xvfa julia-1.0.0-linux-x86_64.tar.gz
COPY mlp.jl /julia-1.0.0/bin/mlp.jl
COPY iterate_benchmarks.jl /julia-1.0.0/bin/iterate_benchmarks.jl
WORKDIR /julia-1.0.0/bin
RUN ./julia -e 'using Pkg; Pkg.add("Flux")'
RUN ./julia -e 'using Pkg; Pkg.add("CuArrays")'
CMD ./julia iterate_benchmarks.jl

Pkg.build isn’t executed by the NVIDIA runtime, so it doesn’t have access to the CUDA driver library which is mounted from the host system. Delayed package installation or build is the only option.
See https://github.com/JuliaGPU/docker for an example.

1 Like

Ok, thanks for the reply!