Celeb Glow
news | March 21, 2026

cuda-samples error when building with Nvidia-Docker?

I'm using Ubuntu 20 and CUDA 11.1

I followed the steps in here:

When I got to sudo nvidia-docker build -t device-query ., it says

unable to locate package cuda-samples
the command '/bin/sh -c apt-get update && apt-get install -y --no-install-recommends
cuda-samples:-$CUDA_PKG_VERSION && -rm -rf /var/lib/apt/lists/*'
returned a non-zero code: 100

The Dockerfile is:

# FROM defines the base image
FROM nvidia/cuda
# RUN executes a shell command
# You can chain multiple commands together with &&
# A \ is used to split long lines to help with readability
# This particular instruction installs the source files
# for deviceQuery by installing the CUDA samples via apt
RUN apt-get update && apt-get install -y --no-install-recommends \ cuda-samples-$CUDA_PKG_VERSION && \ rm -rf /var/lib/apt/lists/*
# set the working directory
WORKDIR /usr/local/cuda-11.1/samples/1_Utilities/deviceQuery
RUN make
# CMD defines the default command to be run in the container
# CMD is overridden by supplying a command + arguments to
# `docker run`, e.g. `nvcc --version` or `bash`
CMD ./deviceQuery

can anyone help?

1

1 Answer

Yes, the nvidia tutorial is not the best. You have to change the Dockerfile like this (see man diff):

2c2
< FROM nvidia/cuda
---
> FROM nvidia/cuda:11.1-devel-ubuntu20.04
9,11c9,11
< RUN apt-get update && apt-get install -y --no-install-recommends \\
< cuda-samples-$CUDA_PKG_VERSION && \
< rm -rf /var/lib/apt/lists/*
---
> RUN apt-get update && \
> apt-get install -y --no-install-recommends cuda-samples-11.1 && \
> rm -rf /var/lib/apt/lists/*
14c14
< WORKDIR /usr/local/cuda-11.1/samples/1_Utilities/deviceQuery
---
> WORKDIR /usr/local/cuda/samples/1_Utilities/deviceQuery

And then start it with

nvidia-docker container run --rm -ti --gpus all device-query

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy