系统环境:ubuntu20.04
安装显卡驱动:
- 驱动下载,我选择的是520.56.06
- 禁用nouveau驱动
echo "blacklist nouveau">>/etc/modprobe.d/blacklist.conf
echo "options nouveau modeset=0">>/etc/modprobe.d/blacklist.conf
sudo update-initramfs -u
- 重启按crtl+alt+f2键进入终端模式:安装以下依赖
sudo apt-get install -y gcc make build-essential
- 安装驱动
执行权限
sudo chmod a+x NVIDIA-Linux-x86_64-xxx.xx.run
运行
sudo ./NVIDIA-Linux-x86_64-xxx.xx.run -no-x-check -no-nouveau-check -no-opengl-files
- 安装过程选项
默认既可,但要Secure Boot(安全启动)为Disabled 或者关闭
安装cuda与duann
- cuda下载,我选择的是11.8
sudo ./cuda_xxx_linux.run
请注意取消选择安装驱动第一个x去掉,x代表选中 2. 配置cuda路径
sudo vim ~/.bashrc
添加如下内容
$ export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
$ export LD_LIBRARY_PATH=/usr/local/cuda/lib64\
${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
source ~/.bashrc
- cudnn安装,我选择的是Local Installer for Linux x86_64 (Tar)
然后解压代码包:
tar -xf xx.archive.tar.xz
复制到对应文件夹下
sudo cp include/cudnn.h /usr/local/cuda/include
sudo cp lib/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
安装docker-gpu
- 安装docker
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo docker run hello-world
设置权限问题 报:Got permission denied while trying to connect to the Docker daemon socket at
sudo gpasswd -a nvidia docker
newgrp docker
- 安装docker-gpu
curl https://get.docker.com | sh \
&& sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
- 设置私有仓库
vim /etc/docker/daemon.json
将以下内容写入
{
"insecure-registries":["http://xx.xxx.xx.xx:xxxx"]
}
再次读入配置信息,并启动
sudo systemctl daemon-reload
sudo systemctl restart docker
安装ssh、ifconfig、vim常用工具
sudo apt install -y net-tools vim
sudo apt install -y --no-install-recommends openssh-server
service ssh start
参考文献
- 显卡驱动:
https://blog.csdn.net/weixin_42341590/article/details/109563412 - cuda+cudnn
https://blog.csdn.net/h3c4lenovo/article/details/119003405 - docker gpu
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html https://docs.docker.com/engine/install/ubuntu/
|