赞
踩
博主由于视觉开发需求, 配置nvidia驱动并映射到docker中运行, 在本文中记录过程及遇到的问题
Static hostname: debian
Icon name: computer-desktop
Chassis: desktop
Operating System: Debian GNU/Linux 11 (bullseye)
Kernel: Linux 5.10.0-19-amd64
Architecture: x86-64
CPU: 12th Gen Intel(R) Core(TM) i7-12700F
GPU: Nvidia Quadro M2000
根据自己的显卡型号去官网搜索对应的驱动程序. 本机选择470.161…03版本驱动.
NVIDIA 驱动程序下载 官方高级驱动搜索
cuda对应驱动版本要求对照表:
NVIDIA CUDA Toolkit Release Notes
注意!
apt-get install nvidia-driver
时不可运行(can not communicate with nvidia driver 类似报错)sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
禁用后重启计算机
sudo reboot
后续编译使用的依赖软件2
sudo apt-get install gcc g++ cmake pkg-config libglvnd-dev
sudo apt-get install linux-headers-$(uname -r|sed 's/[^-]*-[^-]*-//')
sudo service gdm3 stop
输入该行指令后会进入命令行状态, 此时只有一个光标, 通过按Ctrl + Alt + F1
和Ctrl + Alt + F2
即可跳出输入用户名密码的指令行.
chmod +x ~/Downloads/NVIDIA-Linux-x86_64-470.161.03.run
# 需要以管理员权限运行
sudo ~/Downloads/NVIDIA-Linux-x86_64-470.161.03.run
中间弹窗可以按照以下几个选项:
Are you sure you want to continue? -> CONTINUE INSTALLATION
Would you like to run the nvidia-xconfig utility? -> YES
安装完成后, 重启计算机并删除禁用nouveau时创建的blacklist
文件
nvidia-smi
# 输出
Thu Mar 9 14:22:29 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.161.03 Driver Version: 470.161.03 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Quadro M2000 Off | 00000000:01:00.0 On | N/A |
| 63% 59C P0 38W / 75W | 769MiB / 4041MiB | 30% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1835 G /usr/lib/xorg/Xorg 282MiB |
| 0 N/A N/A 1982 G /usr/bin/gnome-shell 110MiB |
| 0 N/A N/A 30799 G gnome-control-center 39MiB |
+-----------------------------------------------------------------------------+
安装可以参考此文如何建立并使用docker
nano nvidia-container-runtime-script.sh
curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | \
sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update
nvidia-container-runtime-script.sh
sudo apt-get install nvidia-container-runtime
sudo systemctl restart docker # 重启docker
which nvidia-container-runtime-hook
/usr/bin/nvidia-container-runtime-hook
docker pull nvidia/cuda:11.3.1-base-ubuntu20.04
docker run --gpus all --rm -it nvidia/cuda:11.3.1-base-ubuntu20.04 bash
nvidia-smi
#输出如下, 说明运行成功:
root@8a57ae3075d7:/# nvidia-smi
Thu Mar 9 06:42:20 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.161.03 Driver Version: 470.161.03 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Quadro M2000 Off | 00000000:01:00.0 On | N/A |
| 62% 53C P0 28W / 75W | 761MiB / 4041MiB | 34% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
卸载安装的驱动可以使用4:
sudo apt-get --purge remove "*nvidia*"
sudo /usr/bin/nvidia-uninstall
本文用来记录Debian11在安装nvidia驱动和docker运行时遇到的一些问题, 由于是事后补写可能中间有些异常处理略有缺漏, 各位同学有问题可以留言交流.
显卡驱动报错:NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver.
固件错误Possible missing firmware解决办法
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。