服务器刚装的系统,还未配置显卡驱动,无法使用nvidia-smi指令。使用如下指令,查看显卡
lspci | grep -i nvidia

显示结果: 两张 Device 20f1,在查询网址可以查到对应的显卡
A100 显卡, 40GB

vim /etc/modprobe.d/blacklist.conf
在conf文件最后一行添加blacklist nouveau,保存文件并退出。
sudo update-initramfs -u
reboot
输入下列命令行,没有输出,则表示正常。
lsmod | grep nouveau
下载对应版本的.run文件
nvidia驱动下载地址

修改权限
sudo chmod 777 NVIDIA-Linux-*******.run //NVIDIA-Linux-*******.run 表示你下载的驱动程序安装文件
sudo sh ./NVIDIA-Linux-*******.run -no-opengl-files //NVIDIA-Linux-*******.run 表示你下载的驱动程序安装文件
等待
4. nvidia-smi验证

cuda11.5.1安装链接
按照下面的命令来即可

cudnn安装链接
Tar File Installation
# Before issuing the following commands, you'll need to replace X.Y and v8.x.x.x with your specific CUDA and cuDNN versions and package date.
1. Procedure
2. Navigate to your <cudnnpath> directory containing the cuDNN tar file.
3. Unzip the cuDNN package.
$ tar -xvf cudnn-linux-x86_64-8.x.x.x_cudaX.Y-archive.tar.xz
4. Copy the following files into the CUDA toolkit directory.
$ sudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include
$ sudo cp -P cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

自己找官方的文档即可,没必要网上找教程…
踩坑一堆
先创建多用户,参考教程
由于root用户下,已经创建了anaconda和cuda的环境,新建用户后
su root
注:4.2节应该先执行
vim ~/.condarc
自己更新conda的配置如下
auto_activate_base: false
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
vim ~/.bashrc
打开后,添加如下
export PATH=$PATH:/usr/local/cuda-11.5/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.5/lib64
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-11.5/lib64
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/xxx/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/xxx/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/xxx/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/xxx/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
使环境变量生效
source ~/.bashrc
由于有一个代码在pytorch1.12.1环境下无法运行,
因此重新下载一个低版本的pytorch1.7.1,找了较多的方法…
pyttorch官网pip下载即可
