# Trouble building Docker container with CuArrays

**URL:** <https://discourse.julialang.org/t/trouble-building-docker-container-with-cuarrays/22347>\
**Category:** GPU\
**Created:** [March 26, 2019, 11:41am UTC](https://discourse.julialang.org/t/trouble-building-docker-container-with-cuarrays/22347 "2019-03-26T11:41:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![edwardchalstrey1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/edwardchalstrey1/32/7612_2.png) [@edwardchalstrey1](https://discourse.julialang.org/u/edwardchalstrey1)\
**Post date:** [March 26, 2019, 11:41am UTC](https://discourse.julialang.org/t/trouble-building-docker-container-with-cuarrays/22347/1 "2019-03-26T11:41:51Z")

</div>

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?

```julia
FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
RUN apt-get update \ &amp;&amp; apt-get install -y wget \ &amp;&amp; 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

```

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [March 26, 2019, 11:45am UTC](https://discourse.julialang.org/t/trouble-building-docker-container-with-cuarrays/22347/2 "2019-03-26T11:45:27Z")

</div>

`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](https://github.com/JuliaGPU/docker) for an example.

---

<div class="post-metadata">

**Author:** ![edwardchalstrey1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/edwardchalstrey1/32/7612_2.png) [@edwardchalstrey1](https://discourse.julialang.org/u/edwardchalstrey1)\
**Post date:** [March 26, 2019, 2:32pm UTC](https://discourse.julialang.org/t/trouble-building-docker-container-with-cuarrays/22347/3 "2019-03-26T14:32:36Z")

</div>

Ok, thanks for the reply!
