Ubuntu 20.04 install CUDA


To record my experience on installing CUDA on Ubuntu 20.04.

1. Pre-procedure before install

(More details can be found in [1] [2])

1.1 Verify the system has a CUDA-capable GPU.

lspci | grep -i nvidia

If your graphics card is from NVIDIA and it is listed in https://developer.nvidia.com/cuda-gpus, your GPU is CUDA-capable.

1.2 Verify the system is running a supported version of Linux.

uname -m && cat /etc/*release

1.3 Verify the system has gcc installed.

gcc --version

1.4 Verify the system has the correct kernel headers and development packages installed.

uname -r

1.5 Remove previously installed CUDA toolkit

sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*" 

1.6 Remove previously installed CUDA driver

sudo apt-get --purge remove "*nvidia*"

1.7 Remove possible files

sudo rm -rf /usr/local/cuda*

2. Install CUDA

2.1 Choose your CUDA version and installation method

Go to official website and follow their instructions to download corresponding version of CUDA and installation method. Local and network are both recommended. For example, CUDA Toolkit 11.6 deb[network].

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
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda

2.2 Reboot

sudo reboot

Reboot and then set security key. When using the command to reboot, choose MOK.

2.3 First-round Check

nvdia-smi

‘nvdia-smi’ should show information about your GPU.

nvcc --version

If it also returns the correct version of CUDA, you have completed.
If ‘nvcc --version’ can not found anything or raise an error, use the following command

whereis nvcc

If it returns ‘nvcc:’, don’t worry and please do the remaining steps.

2.4 Add CUDA to path

sudo nano ~/.bashrc

Open the file and add the following texts to the last of this file

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

Remember to change ‘11.4’ to the version you want to install.

2.5 Second-round Check

Both of the following commands should work now.

nvdia-smi
nvcc --version
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值