Ubuntu – Install CUDA to different directory in 16.04

cudadirectorysoftware installation

Is it possible to install CUDA to a directory other than /usr/local/? I have very limited space on my drive. I'm using this answer to install it currently.

I'm using it for TensorFlow.

Best Answer

Refer the NVIDIA's CUDA Installation Guide page 32/33(_according to PDF reader page 36/37) for more details on how to install at the custom location for the CUDA libaries, and also what environment variables to set to make it work.

Update:
As per the documentation:

Runfile
The Runfile can be extracted into the standalone Toolkit, Samples and Driver Runfiles by using the --extract parameter. The Toolkit and Samples standalone Runfiles can be further extracted by running:

$ ./runfile.run --tar mxvf

The Driver Runfile can be extracted by running:

$ ./runfile.run -x

...
For debian systems:

$ dpkg-deb -x  package.deb output_dir
# Where package.deb is the downloaded debian package for cuda 
# and output_dir is the directory where you want to extract the files.

Update 2:

As commented by the OP the installation guide page 34 ( PDF Reader Page 38) contains the necessary steps/references posted below for reference here:

How do I install the Toolkit in a different location?

The Runfile installation asks where you wish to install the Toolkit and the 
Samples during an interactive install. If installing using a non-interactive 
install, you can use the --toolkitpath and --samplespath parameters to 
change the install location:
$ ./runfile.run --silent \
  --toolkit --toolkitpath=/my/new/toolkit \
  --samples --samplespath=/my/new/samples


The RPM and Deb packages cannot be installed to a custom install location 
directly using the package managers. See the "Install CUDA to a specific 
directory using the Package Manager installation method" scenario in the 
Advanced Setup section for more information.
Related Question