1

I need to run a cuda binary on kubernetes. I've set up the nodes to use the kubernetes nvidia device plugin with nvidia-docker2. Here is my Dockerfile:

FROM ubuntu:18.04
COPY addarrays /addarrays
ENTRYPOINT [ "/addarrays" ]

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

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.

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

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" ]

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

E: Unable to locate package software-properties-common

What do I need to do to get an nvidia driver installed in my docker image?

Dean Schulze
  • 9,633
  • 24
  • 100
  • 165

1 Answers1

3

You have to do the apt update first. On install commands you should use the -y flag. Also you should concatenate the commands into a single run command.

FROM ubuntu:18.04

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

COPY addarrays /addarrays

ENTRYPOINT [ "/addarrays" ]
Chris
  • 5,109
  • 3
  • 19
  • 40
  • I'd first `add-apt-repository` and then `apt install` (both at once). There's no need to `apt-update`, because there won't be anything which it could update and it has to fetch anyway. – Martin Zeitler Jun 29 '22 at 15:23
  • That wont work because you can not install `software-properties-common` without the `apt update` before, which you need to run the `add-apt-repository` command. The `apt update` afterwards isn't required, since on ubuntu 18.04 and newer the add-apt-repository will also update the package index by default. – Chris Jun 29 '22 at 15:40
  • I've thought `add-apt-repository` was already present; I often just inject yum/dnf config files, despite there is `dnf config-manager` for it on these distributions. – Martin Zeitler Jun 29 '22 at 16:01