ubuntu.24安装cuda
1.下载CUDA Toolkit
https://developer.nvidia.com/cuda-toolkit-archive
2.按照命令下载,安装
sudo sh cuda_12.2.2_535.104.05_linux.run
3.环境变量
sudo vi /etc/profile
最后面添加
export PATH=“/usr/local/cuda-12.2/bin:
P
A
T
H
"
e
x
p
o
r
t
L
D
L
I
B
R
A
R
Y
P
A
T
H
=
"
/
u
s
r
/
l
o
c
a
l
/
c
u
d
a
−
12.2
/
l
i
b
64
:
PATH" export LD_LIBRARY_PATH="/usr/local/cuda-12.2/lib64:
PATH"exportLDLIBRARYPATH="/usr/local/cuda−12.2/lib64:LD_LIBRARY_PATH”
重启
reboot
检查
nvcc -V
4.Removing CUDA Toolkit and Driver
Ubuntu and Debian
To remove CUDA Toolkit:
sudo apt-get --purge remove “cuda” “cublas” “cufft” “cufile” “curand”
“cusolver” “cusparse” “gds-tools” “npp” “nvjpeg” “nsight*” “nvvm”
To remove NVIDIA Drivers:
sudo apt-get --purge remove “nvidia” “libxnvctrl*”
To clean up the uninstall:
sudo apt-get autoremove
5.官方文档
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/contents.html
6.安装cuddn
https://developer.nvidia.cn/rdp/cudnn-archive
sudo tar -xf cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz
cd cudnn-linux-x86_64-8.9.7.29_cuda12-archive/
sudo cp lib/libcudnn* /usr/local/cuda-12.2/lib64
sudo cp include/* /usr/local/cuda-12.2/include
sudo chmod a+r /usr/local/cuda-12.2/include/cudnn.h
sudo chmod a+r /usr/local/cuda-12.2/lib64/libcudnn*
#测试
cat /usr/local/cuda-12.2/include/cudnn_version.h | grep CUDNN_MAJOR -A 2