1. 安装显卡驱动550版本:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-drivers
命令来源于:
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_network
安装完成后重启,重启之后可以输入nvidia-smi命令验证:
xiaxinkai@msi:~$ nvidia-smi
Sat Apr 27 23:51:11 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.54.15 Driver Version: 550.54.15 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 1060 Off | 00000000:01:00.0 On | Off |
| 0% 37C P8 26W / 100W | 494MiB / 1024MiB | 3% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 1698 G /usr/lib/xorg/Xorg 118MiB |
| 0 N/A N/A 1842 G /usr/bin/gnome-shell 138MiB |
| 0 N/A N/A 3223 G ...seed-version=20240426-130149.177000 59MiB |
| 0 N/A N/A 3759 G ...irefox/3836/usr/lib/firefox/firefox 159MiB |
+-----------------------------------------------------------------------------------------+
2. 安装CUDA toolkit 12.4.1:
sudo apt-get -y install cuda-toolkit-12-4
3. 为CUDA12.4在.bashrc中添加环境变量
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
4. 验证CUDA toolkit 12.4.1安装成功
xiaxinkai@msi:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Mar_28_02:18:24_PDT_2024
Cuda compilation tools, release 12.4, V12.4.131
Build cuda_12.4.r12.4/compiler.34097967_0