Go to the official website to download the cuda.deb file
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.4.4/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.4-470.82.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.4-470.82.01-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
Finally, nvcc -V checks the cuda version
There are mainly two versions, so you need to uninstall one
Found that the versions do not match, uninstall the previously installed nvidia-cuda-toolkit (before nvcc was prompted to install nvidia-cuda-toolkit)
sudo apt-get autoremove nvidia-cuda-toolkit
Found nvcc executable file
再export PATH=$PATH:/usr/local/cuda/bin
Then nvcc --version found the installed cuda11.4