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.
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.
Download the (local) .run
file from the CUDA downloads page.
Consulting NVIDIA's CUDA Installation Guide page 34 (PDF page 38):
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
Where /my/new/
is your new CUDA install directory (on a partition with sufficient space). Previously, it was installed to /usr/local/cuda/
or /usr/local/cuda-x.x
.
The folders /my/new/toolkit
and /my/new/samples
are created automatically.
Also, I found it useful to use the --tmpdir=/some/path/
flag, which sets which directory to temporarily store the files. Use a directory in a partition with a lot of space.
So finally, the command becomes:
$ ./runfile.run --silent --toolkit --toolkitpath=/my/new/toolkit --samples --samplespath=/my/new/samples --tmpdir=/my/new/
You can run the above with the --help
flag or consult the CUDA Linux docs to see all installation possibilities.
After this, it is necessary to redirect the PATH
and LD_LIBRARY_PATH
variables. Add the following lines to the bottom of your .bashrc
file (which is in your home directory):
export PATH=/my/new/toolkit/bin/:$PATH
export LD_LIBRARY_PATH=/my/new/toolkit/lib64/:$LD_LIBRARY_PATH
You must then run source /home/username/.bashrc
to run the file and load the environment variables.
Run nvcc --version
to confirm that CUDA is installed. Get the version with cat /my/new/toolkit/version.txt
.
See this answer for more help.
This part was specific to my use-case, but to install TensorFlow with Anaconda after installing CUDA, run conda install -c jjhelmus tensorflow-gpu
(from here. The Anaconda one doesn't seem to work).
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.
$ ./runfile.run --silent \ --toolkit --toolkitpath=/my/new/toolkit \ --samples --samplespath=/my/new/samples
.
– Abhishek Divekar
Aug 03 '17 at 16:34
In my case I required a custom location for all like toolkit
, samples
, librray
. So instead of setting all separately I used --installpath=<path>
which I got to know about by running ./cuda-installer.run --help
I was installing cuda 10.2 linux toolkit