Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
发挥NVIDIA PRIME的全部功力:真·自动切换(三)
Experiences and Insight
1246
views ·
0
replies ·
To
floor
Go
risez
deepin
2020-10-03 03:51
Author
本帖最后由 risez 于 2020-10-2 22:36 编辑
自动配置
上述配置都是手动方式,而且在你重启之后那些配置就会失效了,我为何还要讲手动配置方式,就是为了让大家更好的理解并使用这些功能,现在将讲述自动配置方式。首先在/lib/udev/rules.d/新建一个名为80-nvidia-pm.rules的文件,请看如下内容:
# Remove NVIDIA USB xHCI Host Controller devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
# Remove NVIDIA USB Type-C UCSI devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"
# Remove NVIDIA Audio devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"
# Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto"
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto"
# Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on"
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on"
Copy the Code
上述内容均为官方文档提供的内容。等等!别这么快添加内容到文件并保存!不根据自己的实际情况修改内容,直接复制粘贴就完事,一旦出了问题很难找到根源所在!为了能减少不必要的折腾,请耐心看下去,一步一步把内容改成自己实际需要的样子。
首先查看你的内核版本:
uname -r
Copy the Code
这是我的输出:
5.8.12-arch1-1
Copy the Code
假设你的独显有4个接口,如果你的内核版本大于4.19且小于5.3,启用function 0和function 1,删除function 3和function 4;如果你的内核大于5.3,启用全部功能享受极致快乐!
现在,根据自身实际情况启用对应的功能:
function 0大家肯定都有,所以必须启动:
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto"
Copy the Code
有几个参数需要注意:
ATTR{vendor}=="0x10de":该参数中的"0x10de"是Nvidia的PCI vendor ID,如何确定我的机器上的独显的PCI vendor ID是什么?输入以下命令确定:
lspci -n | grep 01.00.0
Copy the Code
这是我的输出:
01:00.0 0300: 10de:1f91 (rev a1)
Copy the Code
注意那个10de:1f91,意思是:,我们只需得到即10de就行了,然后你在把这个值写入文件时写成0x + 10de的形式比如0x10de就可以了。
你还可以运行nvidia-settings,然后直接在软件界面(Graphics Card Information)就可以查到这两个ID了。
ATTR{class}=="0x030000":这个用nvidia-settings不能查到,所以只能用命令行方式。
输入命令:
dmesg | grep class | grep 10de
Copy the Code
这是我的输出:
[ 0.364750] pci 0000:01:00.0: [10de:1f91] type 00 class 0x030000
[ 0.365077] pci 0000:01:00.1: [10de:10fa] type 00 class 0x040300
Copy the Code
注意输出中类似于0000:01:00.0的内容,去掉0000:即可得到熟悉的bus id(01:00.0),因此确定function 0的class id为0x030000,同理,function 1的class id为0x040300,以此类推。
由于本机中只有两个接口,所以我在文件中添加了如下内容:
# Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto"
Copy the Code
如果你的机器因为该配置文件出现了问题,很可能是另外三个驱动工作不正常,那就直接删除,删除后三个接口的电源将一直保持关闭状态:
# Remove NVIDIA USB xHCI Host Controller devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
# Remove NVIDIA USB Type-C UCSI devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"
# Remove NVIDIA Audio devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"
Copy the Code
记得根据实际情况替换ATTR{vendor}和ATTR{class}的值,以及根据接口数删除不必要的配置。
本文所有部分链接:
一:https://bbs.deepin.org/post/203224#=1##pid786085
二:https://bbs.deepin.org/post/203225#=1##pid786087
三:https://bbs.deepin.org/post/203226#=1##pid786088
四:https://bbs.deepin.org/post/203227#=1##pid786089
五:https://bbs.deepin.org/post/203228#=1##pid786090
Reply
Like 0
Favorite
View the author
All Replies
No replies yet
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
The settings menu needs to be translated into Russian.
the Network section no longer appears
Error during system installation
Deepin IDE?
Deepin Native Apps not launching in the latest version
Music player with sample rate and bit depth
Popular Events
More
自动配置
本文所有部分链接:
一:https://bbs.deepin.org/post/203224#=1##pid786085
二:https://bbs.deepin.org/post/203225#=1##pid786087
三:https://bbs.deepin.org/post/203226#=1##pid786088
四:https://bbs.deepin.org/post/203227#=1##pid786089
五:https://bbs.deepin.org/post/203228#=1##pid786090