1. Download the file.
Go to the official website link below to download the version you need. I like 11.7
CUDA Toolkit Archive | NVIDIA Developer
2. Installation
Possible errors:
Failed to verify gcc version. --Linux installation CUDA GCC version is not compatible
sudo sh cuda_xxxxxxxxxxxxxx_linux.run --override
With this override, you can overcome the gcc version incompatibility problem.
If prompted Existing package manager installation of the driver found. It is strongly recommended that you remove this before continuing., select continue, remove the driver item in the next step, and then select install:
3. Set environment variables
Double-click to open the .bashrc file in the above picture (note that this is a hidden file, so you need to display the hidden file), add the following three lines.
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda/extras/CPUTI/lib64
export CUDA_HOME=/usr/local/cuda/bin
export PATH=$PATH:$LD_LIBRARY_PATH:$CUDA_HOME
After that, execute the following code on the command line to make the environment variable take effect
source ~/.bashrc
4. Verify that cuda is installed successfully
nvcc -V