cuda samples installation

During installation with a .run file, it always ask whether to install samples or not. However, it seems there is always a “samples” directory under cuda directory after installation, regardless you choose to install samples or not. If you choose to install samples, it will just put another sample directory to the path you assigned. So what is the point of asking to install samples or not?

The question asking to install samples or not is related to installing an additional copy in a (possibly) non-system location.

For example, on linux, the default system location for storage of CUDA is /usr/local

This is not a writable location for an ordinary user. The prompt in the toolkit installer allows you to install the samples in another location, which might be writable for a particular user.

There are various ways that this might be useful. I’m not going to argue about whether this is the best possible way to solve these cases from a particular point of view. If you’d like to see a change to CUDA behavior, you’re encouraged to file a bug, instructions linked to sticky post at top of CUDA programming forum.

One possible use-case:

I am an ordinary user on a system, and don’t have root access. I dont’ want to install the CUDA toolkit, it is already installed. I want my own writable copy. And the sysadmins have not provided (i.e. deleted, or used their own installation method) the /usr/local/cuda/samples directory. I can run the CUDA toolkit installer, deselect every option except installation of samples.

Another possible use-case:

I am an ordinary user on a system that has CUDA 10.1.243 installe in the usual location, including samples. For some odd reason, I would like to access a previous version of the samples, say from 10.1.168. I can use this method to install my own off-version of the samples.

If you are doing a normal install, and you don’t want the samples in the usual place (/usr/local/cuda/samples) then just delete that directory. Note that many users have codes that depend on things like helper_cuda.h. This is not recommended practice, but it exists in the real world. For such users/codes, its a matter of convenience to provide /usr/local/cuda/samples/common/inc. I also think its a matter of convenience to just provide the full samples install at the usual location, and also for the sysadmin/root user to kick off a make -k in the samples directory immediately after install, but thats just the way I see things on planet bob.

Thank you very much. It sounds reasonable.


I have created a container with this Nvidia image nvidia/cuda:10.2-devel-ubuntu16.04 and there are no samples under /usr/local folder. Then when I try to build a project that requires helper_cuda.h can’t find it because, in theory, it has to be in the samples folder.

How should I install Cuda in a docker image in order to have the samples into the container?

Thank you,
Jordi Gonzalez Cano

By default the samples would not be in /usr/local but would be in /usr/local/cuda/samples (or /usr/local/cuda-10.2/samples)

One possible approach:

  1. spin up your container image
  2. in the container, do a wget on the CUDA runfile installer for the CUDA version you are using
  3. in the container, run the runfile installer but specify to only install the CUDA samples
  4. thereafter, point your compile include switch at the location where you installed the samples in the container

If you want to automate this, i.e. include all this when you build the container, those instructions should be evident based on the steps above. If you still need help, you may want to look at the dockerfile for the base image you are using, to get general knowledge of how dockerfiles are built and what changes would be needed to do this.

I am trying to get the runfile with the wget and I get this all the time:

2020-01-24 14:41:06--  (try: 4)
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 2645419389 (2.5G), 2642985040 (2.5G) remaining [application/octet-stream]
Saving to: ''

cuda_10.2.89_440.33.01_l   0%[                                   ]   3.07M  --.-KB/s    in 0.08s   

2020-01-24 14:41:06 (8.82 MB/s) - Read error at byte 3216443/2645419389 (Connection reset by peer). Retrying.

I would like to have the samples into an image, so I guess there is a way to avoid installing the drivers and the toolkits and only install the samples without interaction while building the image right?