开始装nvidia 驱动之前先配置nouveau 文件
参考 https://blog.csdn.net/qq_40907977/article/details/115305634
1. 删除原有驱动
bash
sudo apt-get purge nvidia*
sudo apt-get autoremove
2.安装依赖
bash
sudo apt-get install build-essential gcc-multilib dkms
3.禁用nouveau 驱动:
sudo vim /etc/modprobe.d/blacklist-nouveau.conf 文件,
按i 键 添加以下内容:
bash
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
按esc 退出编辑模式,输入:wq!保存
关闭nouveau:
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
4.重启
bash
sudo update-initramfs -u
sudo reboot
开机按Delete 进入BIOS,把Security Boot 改为disable
5.验证nouveau是否禁用成功
重启后,执行:
bash
lsmod | grep nouveau
如果没有屏幕输出,说明禁用nouveau 成功。
二.Nvidia 驱动安装
1.获取kernel source
bash
$ sudo apt-get install linux-source
$ sudo apt-get install linux-headers-$(uname -r)
2.安装命令
官方下载链接:Official Drivers | NVIDIA
bash
sudo sh NVIDIA-Linux-x86_64-470.86.run
sudo ./NVIDIA-Linux-x86_64-470.86.run -no-nouveau-check -no-opengl-files
DKMS NO
32-bit NO
X Yes
三.CUDA 11.1
nvidia-drivers与cuda版本匹配关系:CUDA 12.4 Update 1 Release Notes (nvidia.com)
cuda下载官方链接:CUDA Toolkit 11.1 Update 1 Downloads | NVIDIA Developer
bash
cd /home/wdv4szh/GPUSetup/cuda11.1_packages
chmod +x cuda_11.1.1_455.32.00_linux.run
sudo sh ./cuda_11.1.1_455.32.00_linux.run
把图形界面中 +【】Driver 的X 给去掉
3.sudo vim ~/.bashrc
bash
# set PATH for cuda 11.1 installation
if [ -d "/usr/local/cuda-11.1/bin" ]; then
export PATH=/usr/local/cuda-11.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64:$LD_LIBRARY_PATH
fi
4.source ~/.bashrc
bash
nvcc -V
四:Cudnn
bash
tar -xzvf cudnn-11.1-linux-x64-v8.0.5.39.tgz
拷贝下列文件到CUDA 文件夹
bash
sudo cp cuda/lib64/* /usr/local/cuda-11.1/lib64/
sudo cp cuda/include/* /usr/local/cuda-11.1/include/
验证:
bash
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
五:Anaconda
bash
chmod +x Anaconda3-2021.11-Linux-x86_64.sh
sudo sh ./Anaconda3-2021.11-Linux-x86_64.sh
路径修改为 /usr/local/anaconda3
每次用新用户登录,需要修改配置信息:
命令行输入 sudo vim ~/.bashrc
按i 建在最后添加下方配置信息
bash
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/usr/local/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/usr/local/anaconda3/etc/profile.d/conda.sh" ]; then
. "/usr/local/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/usr/local/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
添加完之后按esc 键,按: 输入wq!
退出后 source ~/.bashrc
打开一个新的窗口验证是否安装成功(base)
bash
#create your virtual env
conda create -n py38pt18 python=3.8
conda activate py38pt18
#install pytorch 1.8
pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f
https://download.pytorch.org/whl/torch_stable.html
六:Vscode
bash
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" >
/etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install code # or code-insiders
参考:https://www.jianshu.com/p/9387d192f377
七:Remote 远程桌面UI
设置远程权限
bash
sudo apt-get install xrdp
安装桌面环境
bash
sudo apt-get install xfce4
sudo apt-get install xfce4-terminal
sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n xfce-session \n' /etc/xrdp/startwm.sh
sudo adduser xrdp ssl-cert
允许防火墙中的RDP 端口
bash
sudo ufw allow 3389/tcp
sudo iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
sudo netfilter-persistent save
sudo netfilter-persistent reload
重启Xrdp 应用
bash
sudo /etc/init.d/xrdp restart
echo xfce4-session >~/.xsession
当work station 没有UI,使用ssh 在windows 远程添加指令