1.安装显卡驱动必要的依赖
yum -y install pciutils
yum install -y epel-release
yum install -y kernel-headers kernel-devel dkms
2.执行shell脚本禁用nouveau驱动
cat >>/lib/modprobe.d/dist-blacklist.conf<<eof
blacklist nouveau
options nouveau modeset=0
eof
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
mv /boot/initramfs-$(uname -r).img.bak /home/initramfs-$(uname -r).img.bak
dracut /boot/initramfs-$(uname -r).img $(uname -r)
systemctl set-default multi-user.target
3.安装驱动Official Advanced Driver Search | NVIDIA
chmod +x NVIDIA-Linux-x86_64-460.106.00.run
sh NVIDIA-Linux-x86_64-460.106.00.run
验证是否安装成功
4.安装cuda?
wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda-repo-rhel7-11-3-local-11.3.0_465.19.01-1.x86_64.rpm
sudo rpm -i cuda-repo-rhel7-11-3-local-11.3.0_465.19.01-1.x86_64.rpm
sudo yum clean all
sudo yum -y install nvidia-driver-latest-dkms cuda
sudo yum -y install cuda-drivers
配置cuda环境变量
vi /etc/profile
文件末尾添加
export CUDA_HOME=/usr/local/cuda-11.3
export PATH=/usr/local/cuda-11.3/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib:$LD_LIBRARY_PATH
刷新环境变量使其生效
source /etc/profile
验证是否安装成功
5.安装cudnn
tar -zxvf cudnn-11.3-linux-x64-v8.2.1.32.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
?6.安装conda
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
chmod +x Anaconda3-2021.11-Linux-x86_64.sh
./Anaconda3-2021.11-Linux-x86_64.sh
source ~/.bashrc
验证是否安装成功
?7.安装pytorch
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
查看是否安装成功
?返回true就是安装成功了
|