[Share Experiences] 【显卡】源内NVIDIA驱动和Blender的CUDA
Tofloor
poster avatar
enforcee
deepin
2021-12-13 00:18
Author

众所周知,deepin源里的显卡驱动很诡异,因此大家都推荐去装NVIDIA官网的驱动包

其实源里的显卡驱动也是能装上的,安装好对应版本的linux-headers,然后装nvidia-driver,最后(Intel和NVIDIA的双显卡)按照debian wiki里写好Xorg配置文件,Lightdm和用户的启动脚本,就能开启独立显卡的独占模式(deepin的Xorg版本低,还不支持官方prime随时切换)

图形界面、屏幕亮度、游戏、glxinfo都正常。打开blender,CUDA不能用(几年前就是这样)

rage

不过这次我突发奇想,用sudo执行blender,居然发现CUDA是可以用的

然后把root的blender关掉,正常运行blender,发现CUDA也能用了

scream

离奇的是重启系统以后,blender的CUDA又不能用了,再sudo,点一下设置的CUDA,普通用户的blender又正常了...

Reply Favorite View the author
All Replies
enforcee
deepin
2021-12-13 07:28
#1

更新:

我发现sudo blender的时候会加载一个内核模块nvidia-uvm

并且之后可以通过modprobe -r nvidia-uvm和modprobe nvidia-uvm来开启和关闭cuda

但是奇怪的是,每次重新启动时手动modprobe nvidia-uvm却没有效果

漏掉什么了吗?

confused

Reply View the author
enforcee
deepin
2021-12-13 07:45
#2

nvidia的README

NVIDIA Unified Memory kernel module (/lib/modules/uname -r /kernel/drivers/video/nvidia-uvm.ko); this kernel module provides functionality for sharing memory between the CPU and GPU in CUDA programs. It is generally loaded into the kernel when a CUDA program is started, and is used by the CUDA driver on supported platforms.

也就是这个模块和CUDA是有关的,并且在运行CUDA程序时加载是正常现象

然而不可能每次用CUDA都要sudo吧

scream

Reply View the author
enforcee
deepin
2021-12-13 08:01
#3

发现了,手动modprobe时/dev/目录是没有nvidia-uvm和nvidia-uvm-tools两个设备文件的

sad

Reply View the author
enforcee
deepin
2021-12-13 08:09
#4

在arch的/usr/lib/udev/rules.d/60-nvidia.conf抄了两条命令

sudo modprobe nvidia-uvm
sudo mknod -Z -m 666 /dev/nvidia-uvm c $(grep nvidia-uvm /proc/devices | cut -d \  -f 1) 0
sudo mknod -Z -m 666 /dev/nvidia-uvm-tools c $(grep nvidia-uvm /proc/devices | cut -d \  -f 1) 1

打开blender

CUDA能用啦

yeah

Reply View the author
enforcee
deepin
2021-12-13 08:12
#5

不过每次都要用sudo很麻烦,准备写个udev规则解决这个问题

blush

奇怪的是其他发行版类似的规则都是已有的,为什么deepin(要么是debian)没有呢?

Reply View the author
justforlxz
deepin
2021-12-13 18:06
#6

我看了一下deepin系统上的,确实没有配置udev规则自动启用,我去研究一下debian看它有没有,我们可以考虑加上这个配置。

Reply View the author
enforcee
deepin
2021-12-13 19:30
#7

更新:

甚至有更简单的命令,原来nvidia已经准备好了

nvidia-modprobe -c0 -u

sweat

Reply View the author
enforcee
deepin
2021-12-13 20:22
#8

创建了

/etc/udev/rules.d/61-nvidia-uvm.rules

DRIVER=="nvidia", RUN+="/usr/bin/nvidia-modprobe -c0 -u"

这回没有任何问题了

yeah

Reply View the author
enforcee
deepin
2021-12-13 20:27
#9
justforlxz

我看了一下deepin系统上的,确实没有配置udev规则自动启用,我去研究一下debian看它有没有,我们可以考虑加上这个配置。

现在是深度的开发者了吗?

辛苦了

yeah

Reply View the author
deepin小粉丝
deepin
2022-06-03 23:37
#10

大佬,sudo blender怎么运行,小白一个。我在百度上找了下也不知道怎么运行

Reply View the author
enforcee
deepin
2022-06-04 00:11
#11
deepin小粉丝

大佬,sudo blender怎么运行,小白一个。我在百度上找了下也不知道怎么运行

你用什么方式安装的blender?如果是系统包管理器安装的,就直接打开终端输入sudo blender回车就行。如果是官网下载的就输入sudo '安装路径/blender',你只需要输入sudo空格,然后在文件管理器里找到安装的位置,然后把blender可执行文件拖到终端窗口里就能快速输入路径。

Reply View the author
deepin小粉丝
deepin
2022-06-07 02:23
#12
enforcee

你用什么方式安装的blender?如果是系统包管理器安装的,就直接打开终端输入sudo blender回车就行。如果是官网下载的就输入sudo '安装路径/blender',你只需要输入sudo空格,然后在文件管理器里找到安装的位置,然后把blender可执行文件拖到终端窗口里就能快速输入路径。

谢谢!

Reply View the author