Solve the problem of inconsistency between ubuntu cuda version nvcc -V and nvidia-smi

Inconsistency when viewing the cuda version with nvcc -V and nvidia-smi:

nvcc -V version is 10.1

The version of nvidia-smi is 12.2

If the version can be displayed above, there is already a driver, and the previous driver must be deleted first:

1. Execute the following command to delete the old version of the driver

sudo apt-get purge nvidia*

At this time, execute nvidia-smi, it will prompt Command 'nvidia-smi' not found, follow the prompts to install:

sudo apt install nvidia-utils-535-server

After the installation is successful, execute nvidia-smi again, it is successful, and the cuda version is displayed as 12.2

2. Download the corresponding version of cuda

CUDA Toolkit 12.2 Downloads | NVIDIA Developer

Just select the corresponding options:

Get the download link:

wget https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run
sudo sh cuda_12.2.0_535.54.03_linux.run

The cuda successful download interface is as follows:

3. Installation

Executing the original command installation will report an error, but the following command succeeds:

sudo sh ./cuda_12.2.0_535.54.03_linux.run --toolkit --silent --override

The above command installed successfully

Execute it again at this time, nvcc -V prompts, Command 'nvcc' not found,..., do not follow the prompts to install nvidia-cuda-toolkit, otherwise, the previous steps will be in vain. At this time, you only need to configure the environment variables:

4. Add environment variables

Execute: vim ~/.bashrc, open the file:

Add (here you need to modify it according to your own directory):

export LD_LIBRARY_PATH=/usr/local/cuda-12.2/lib64
export PATH=$PATH:/usr/local/cuda-12.2/bin

Execute: source ~/.bashrc, effective immediately

Execute again: nvcc -V, successful

This is the end.

 References to this article:

When installing cuda on linux, an error is reported: Existing package manager installation of the driver found.

 CUDA has been installed but nvcc -V shows command not found (Ubuntu20.04LTS system)

https://www.cnblogs.com/ksky-2023/p/17389977.html

Guess you like

Origin blog.csdn.net/qq_18256855/article/details/131692064