<p>I need to run a cuda binary on kubernetes.  I've set up the nodes to use the <a href="https://github.com/NVIDIA/k8s-device-plugin" rel="nofollow noreferrer">kubernetes nvidia device plugin</a> with nvidia-docker2.  Here is my Dockerfile:</p>

<pre><code>FROM ubuntu:18.04
COPY addarrays /addarrays
ENTRYPOINT [ "/addarrays" ]
</code></pre>

<p>When I run the docker image through nvidia-docker2 or kubernetes it gives this error:</p>

<pre><code>Cuda failure addarrays.cu:9: 'CUDA driver version is insufficient for CUDA runtime version' 
Cuda failure addarrays.cu:9: 'CUDA driver version is insufficient for CUDA runtime version' 
Cuda failure addarrays.cu:9: 'CUDA driver version is insufficient for CUDA runtime version' 
Cuda failure addarrays.cu:9: 'CUDA driver version is insufficient for CUDA runtime version' 
Cuda failure addarrays.cu:9: 'CUDA driver version is insufficient for CUDA runtime version' 
Cuda failure addarrays.cu:9: 'CUDA driver version is insufficient for CUDA runtime version' 
addarrays: addarrays.cu:62: int main(): Assertion `hostArrayTmp[i] == hostArrayDest[i]' failed.
</code></pre>

<p>It looks like my docker image needs an nvidia driver.  I've modified the Dockerfile like this:</p>

<pre><code>FROM ubuntu:18.04
RUN apt install software-properties-common
RUN add-apt-repository ppa:graphics-drivers
RUN apt update
RUN apt install nvidia-driver-440
COPY addarrays /addarrays
ENTRYPOINT [ "/addarrays" ]
</code></pre>

<p>The software-properties-common is needed to install add-apt-repository, but it fails with this message:</p>

<pre><code>E: Unable to locate package software-properties-common
</code></pre>

<p>What do I need to do to get an nvidia driver installed in my docker image?</p>

<p>You have to do the <code>apt update</code> first. On install commands you should use the <code>-y</code> flag. Also you should concatenate the commands into a single run command.</p>
<pre><code>FROM ubuntu:18.04

RUN apt update &amp;&amp; \
    apt install software-properties-common -y &amp;&amp; \
    add-apt-repository ppa:graphics-drivers &amp;&amp; \
    apt install nvidia-driver-440 -y

COPY addarrays /addarrays

ENTRYPOINT [ &quot;/addarrays&quot; ]
</code></pre>
