cuda安装


以12.4为例

参考

CUDA Toolkit 12.1 Downloads
https://developer.nvidia.cn/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_network

需要root权限
wget https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run sudo sh cuda_12.4.1_550.54.15_linux.run
接下来的步骤按需执行不一定都要,根据cuda安装方式的不同步骤有些可能不用。

安装完成后配置cuda环境

vim ~/.bashrc
在最后添加
export PATH=$PATH:/usr/local/cuda-12.4/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.4/lib64 export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-12.4/lib64

nvcc -V 配置

sudo vi /usr/bin/nvcc
添加
exec /usr/local/cuda-12.4/bin/nvcc "$@"

然后wq保存退出
输入nvcc -V,如果出现-bash: /usr/bin/nvcc: Permission denied,检查权限

ls -l /usr/bin/nvcc

应该为可执行权限(如 -rwxr-xr-x),如果不是则

sudo chmod +x /usr/bin/nvcc
nvcc-v检查配置成功

驱动更新

使用docker时发现nvidia-container-cli: requirement error: unsatisfied condition: cuda>=12.4, please update your driver to a newer version, or use an earlier cuda container: unknown.
查看nvidia-smi中的Driver Version,CUDA 12.4 需要的最小驱动版本是 525.x,需要更新。理论上可以使用sudo apt-get install -y cuda-drivers安装,但我一直出现The following packages have unmet dependencies: cuda-drivers : Depends: cuda-drivers-560 (= 560.35.03-1) but it is not going to be installedE: Unable to correct problems, you have held broken packages.
于是直接下载安装,具体版本和链接参考
Download The Latest Official NVIDIA Drivers
https://www.nvidia.com/en-us/drivers/

wget https://us.download.nvidia.com/XFree86/Linux-x86_64/550.107.02/NVIDIA-Linux-x86_64-550.107.02.run

下载完成后

chmod +x NVIDIA-Linux-x86_64-550.107.02.run

sudo ./NVIDIA-Linux-x86_64-550.107.02.run

NVIDIA Container Toolkit

如果使用docker的话还需要安装这个

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
sudo apt-get install -y nvidia-container-toolkit
在centos中由于一些源已经停止服务了,需要注释掉对应内容,只要nvidia-container能下载就行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值