I have installed cuda8.0, the latest version. I followed the procedure provided by Nvidia; but, when I type the command nvcc --version it says nvcc is not installed!
What do I do now?
I have installed cuda8.0, the latest version. I followed the procedure provided by Nvidia; but, when I type the command nvcc --version it says nvcc is not installed!
What do I do now?
The problem is [ based on the link you provided ] you haven't added it in the .bashrc. file so it can be seen:
From the terminal:
nano /home/username/.bashrc
or
nano /home/$USER/.bashrc
Inside there add the following: (replace cuda-8.0 with your version)
export PATH="/usr/local/cuda-8.0/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH"
Then do the following to save and close the editor:
On you keyboard press the following:
ctrl + o --> save
enter or return key --> accept changes
ctrl + x --> close editor
Now either do source .bashrc or close and open another terminal
Now run nvcc --version
Information:
.bashrc: is the file read by the terminal before opening and its found in the /home/$USER diretory of the user in question.. before the file means its hidden from view unless you instruct your file manager to show hidden filesThe above solution by @George Udosen is fine. If you want to save the manual procedure, you can automate it by the following:
Create a file add_to_bashrc and add the following to it:
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
export PATH=$PATH:$CUDA_HOME/bin
Create a shell script automate.sh:
(... some installation procedure ...)
cat add_to_bashrc >> ~/.bashrc
. ~/.bashrc
Then you just need to run your shell script:
sh automate.sh
Don't forget to check if the CUDA's shortcut (symLink) works correctly. Simply execute:
ls /usr/local/cuda
For later versions of CUDA (11.7 for me), I followed the below steps:
Go to https://developer.nvidia.com/cuda-downloads and follow the installation instructions.
Inside the ~/.bashrc file, update the path as follows:
export PATH="/usr/local/cuda-11.7/bin:$PATH"`
export LD_LIBRARY_PATH="/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH"
The output of nvcc -V then looks like:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:49:14_PDT_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0
The answer from @George Udosen is perfect.
Just for increment it, you can also export to /usr/local/cuda which is a symbolic link to /usr/local/cuda-10.1, based on this answer. So, you can also write:
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}$
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Terminal:
sudo gedit /home/$USER/.bashrc
Add at the end of the file
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
export PATH=$PATH:$CUDA_HOME/bin
Then terminal:
source .bashrc
Now run
nvcc --version
1st Edit written on Mar 16, 2024
I am using Asus VivoBook X540UBR (date: 01/08/2020) which comes with entry level NVIDIA GeForce MX110.
2 years ago, I abandoned Windows 10 and re-installed the notebook with Linux Mint 21.2 Cinnamon.
To my surprise, Linux has properly installed and maintained NVIDIA drivers via
$ sudo apt update
$ sudo apt dist-upgrade
I don't need to explicitly install Cuda toolkit from https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_local nor explicitly configure the environment path.
However, I installed Cuda toolkit as hinted by apt via
$ sudo apt install nvidia-cuda-toolkit
Then, my GPU environment is ready.
To check the Cuda version in Ubuntu/Mint:
$ nvidia-smi
+--------------------------------------------------------------------------+
| NVIDIA-SMI 535.161.07 Driver Version: 535.161.07 CUDA Version: 12.2 |
|----------------------------+----------------------+----------------------+
... (ignore the rest) ...
To check whether Cuda toolkit is installed:
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0
I am in the middle of studying https://youtu.be/Z_ikDlimN6A?t=4906 and installed pytorch=1.10.0.
>>> import torch
>>> print(torch.cuda.is_available())
>>> print(torch.__version__)
True
1.10.0
2nd Edit written on Feb 03, 2025
I have another Lenovo Yoga 500 (I purchased on 31-Jul-2016), I installed with Ubuntu 24.04. NVidea GPU is not automatically recognized.
I executed the following:
$ ubuntu-drivers devices
(ignore...)
vendor : NVIDIA Corporation
model : GM108M [GeForce 940M]
driver : nvidia-driver-535 - distro non-free
driver : nvidia-driver-470-server - distro non-free
driver : nvidia-driver-550 - distro non-free **recommended**
driver : nvidia-driver-535-server - distro non-free
driver : nvidia-driver-470 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
We can see nvidia-driver-550 is recommended.
I executed the following to install the nvidia driver,
$ sudo apt install nvidia-driver-550
or you can let the following command to do autonomous installation,
$ sudo ubuntu-drivers autoinstall
During the installation, there is MOK Enroll (Machine Owner Key) blue screen that we need to enter a random password. After the installation, reboot the machine.
$ sudo reboot
During machine startup, we'll be presented with MOK Enroll blue screen again. You must select MOK Enroll and enter the previous random password.
In case you accidentally skipped MOK Enroll blue screen, execute the following command to manually trigger MOK Enroll status for next startup.
$ sudo update-secureboot-policy --new-key
$ sudo update-secureboot-policy --enroll-key
$ sudo reboot
The above solution by @Agile Bean is fine. If you want to you can use the env var CUDA_HOME instead of /usr/local/cuda in the LD_LIBRARY_PATH and edit your .bashrc or .zshrc file or the resource file for your shell with emacs or vi or nano or your favorite editor:
emacs $HOME/.zshrc
Add the following lines to the .zshrc file export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATHlrwxrwxrwx 1 root root 20 Sep 11 19:59 =$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64
export PATH=$PATH:$CUDA_HOME/bin
(base) ➜ ~ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:49:14_PDT_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0
(base) ➜ ~ which nvcc
/usr/local/cuda/bin/nvcc
Where is cuda really located? Let's follow the symbolic links to find out.
(base) ➜ ~ ls -ld /usr/local/cuda
/usr/local/cuda -> /etc/alternatives/cuda
(base) ➜ ~ ls -ld /etc/alternatives/cuda
/etc/alternatives/cuda -> /usr/local/cuda-11.7