“使用专用显卡启动”究竟是做什么的?

Kry*_*ten 8 graphics drivers

有许多关于 Ubuntu 中的“使用专用显卡启动”选项的问题:例如,this onethis onethis one。但他们都没有问我真正想知道的问题。

我想了解此选项的作用,尤其是在我的系统环境中:主板集成了 Intel 显卡和 Nvidia 显卡。我在 Nvidia 卡上的端口上连接了三台显示器,而板载图形上没有连接任何东西。

当我看到“使用专用显卡启动”时,我会想象这样的事情:桌面正在运行(使用硬件并在内存中呈现)集成显卡和我刚刚打开的这个窗口的内容此选项在其他显卡上运行,并且输出以某种方式通过集成显卡传输(有点像“画中画”?)。

但鉴于我根本没有使用板载显卡,我的应用程序不是已经在专用显卡上运行了吗?

我怀疑我对这个选项的理解是错误的。任何人都可以澄清这个选项的作用吗?

Shr*_*gde 12

我有完全相同的问题,诸如__GLX_VENDOR_LIBRARY_NAME=nvidia__NV_PRIME_RENDER_OFFLOAD=1、 、 之__VK_LAYER_NV_optimus=NVIDIA_only类的变量都没有DRI_PRIME=1产生相同的结果。

\n

我什至尝试在 gnome-shell 源代码中搜索,但这些函数不在 gnome-shell 存储库中。

\n

我终于偶然发现了 switechroo-controls 包,

\n

我尝试switcherooctl launch <command>复制 gnome shell 行为。\n然后我突然顿悟,在 gnome-shell 存储库中搜索 switcheroo。

\n
\xe2\x9d\xaf grep -ri \'switcheroo\' \nBinary file .git/index matches\ndata/dbus-interfaces/net.hadess.SwitcherooControl.xml:      net.hadess.SwitcherooControl:\ndata/dbus-interfaces/net.hadess.SwitcherooControl.xml:      check the value of net.hadess.SwitcherooControl.HasDualGpu to see\ndata/dbus-interfaces/net.hadess.SwitcherooControl.xml:      The object path will be "/net/hadess/SwitcherooControl".\ndata/dbus-interfaces/net.hadess.SwitcherooControl.xml:  <interface name="net.hadess.SwitcherooControl">\njs/ui/appDisplay.js:        this._switcherooNotifyId = global.connect(\'notify::switcheroo-control\',\njs/ui/appDisplay.js:        this._switcherooProxy = global.get_switcheroo_control();\njs/ui/appDisplay.js:        if (this._switcherooProxy) {\njs/ui/appDisplay.js:            let prop = this._switcherooProxy.get_cached_property(\'HasDualGpu\');\nsrc/meson.build:dbus_generated += gnome.gdbus_codegen(\'switcheroo-control\',\nsrc/meson.build:  \'../data/dbus-interfaces/net.hadess.SwitcherooControl.xml\',\nsrc/shell-app.c:#include "switcheroo-control.h"\nsrc/shell-app.c:  proxy = shell_global_get_switcheroo_control (global);\nsrc/shell-app.c:      g_warning ("Could not apply discrete GPU environment, switcheroo-control not available");\nsrc/shell-app.c:  variant = shell_net_hadess_switcheroo_control_get_gpus (SHELL_NET_HADESS_SWITCHEROO_CONTROL (proxy));\nsrc/shell-app.c:  g_debug ("Could not find discrete GPU in switcheroo-control, not applying environment");\nsrc/shell-global.c:#include "switcheroo-control.h"\nsrc/shell-global.c:  GDBusProxy *switcheroo_control;\nsrc/shell-global.c:  GCancellable *switcheroo_cancellable;\nsrc/shell-global.c:  PROP_SWITCHEROO_CONTROL,\nsrc/shell-global.c:got_switcheroo_control_gpus_property_cb (GObject      *source_object,\nsrc/shell-global.c:        g_debug ("Could not get GPUs property from switcheroo-control: %s", error->message);\nsrc/shell-global.c:  g_dbus_proxy_set_cached_property (global->switcheroo_control, "GPUs", gpus);\nsrc/shell-global.c:  g_object_notify (G_OBJECT (global), "switcheroo-control");\nsrc/shell-global.c:switcheroo_control_ready_cb (GObject      *source_object,\nsrc/shell-global.c:  ShellNetHadessSwitcherooControl *control;\nsrc/shell-global.c:  control = shell_net_hadess_switcheroo_control_proxy_new_for_bus_finish (res, &error);\nsrc/shell-global.c:        g_debug ("Could not get switcheroo-control GDBusProxy: %s", error->message);\nsrc/shell-global.c:  global->switcheroo_control = G_DBUS_PROXY (control);\nsrc/shell-global.c:  g_debug ("Got switcheroo-control proxy successfully");\nsrc/shell-global.c:  cached_props = g_dbus_proxy_get_cached_property_names (global->switcheroo_control);\nsrc/shell-global.c:      g_object_notify (G_OBJECT (global), "switcheroo-control");\nsrc/shell-global.c:  g_dbus_connection_call (g_dbus_proxy_get_connection (global->switcheroo_control),\nsrc/shell-global.c:                          g_dbus_proxy_get_name (global->switcheroo_control),\nsrc/shell-global.c:                          g_dbus_proxy_get_object_path (global->switcheroo_control),\nsrc/shell-global.c:                                         g_dbus_proxy_get_interface_name (global->switcheroo_control),\nsrc/shell-global.c:                          global->switcheroo_cancellable,\nsrc/shell-global.c:                          got_switcheroo_control_gpus_property_cb,\nsrc/shell-global.c:    case PROP_SWITCHEROO_CONTROL:\nsrc/shell-global.c:      g_value_set_object (value, global->switcheroo_control);\nsrc/shell-global.c:switcheroo_appeared_cb (GDBusConnection *connection,\nsrc/shell-global.c:  g_debug ("switcheroo-control appeared");\nsrc/shell-global.c:  shell_net_hadess_switcheroo_control_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,\nsrc/shell-global.c:                                                         "net.hadess.SwitcherooControl",\nsrc/shell-global.c:                                                         "/net/hadess/SwitcherooControl",\nsrc/shell-global.c:                                                         global->switcheroo_cancellable,\nsrc/shell-global.c:                                                         switcheroo_control_ready_cb,\nsrc/shell-global.c:switcheroo_vanished_cb (GDBusConnection *connection,\nsrc/shell-global.c:  g_debug ("switcheroo-control vanished");\nsrc/shell-global.c:  g_clear_object (&global->switcheroo_control);\nsrc/shell-global.c:  g_object_notify (G_OBJECT (global), "switcheroo-control");\nsrc/shell-global.c:  global->switcheroo_cancellable = g_cancellable_new ();\nsrc/shell-global.c:                    "net.hadess.SwitcherooControl",\nsrc/shell-global.c:                    switcheroo_appeared_cb,\nsrc/shell-global.c:                    switcheroo_vanished_cb,\nsrc/shell-global.c:  g_cancellable_cancel (global->switcheroo_cancellable);\nsrc/shell-global.c:  g_clear_object (&global->switcheroo_cancellable);\nsrc/shell-global.c:                                   PROP_SWITCHEROO_CONTROL,\nsrc/shell-global.c:                                   g_param_spec_object ("switcheroo-control",\nsrc/shell-global.c:                                                        "switcheroo-control",\nsrc/shell-global.c:                                                        "D-Bus Proxy for switcheroo-control daemon",\nsrc/shell-global.c: * shell_global_get_switcheroo_control:\nsrc/shell-global.c: * Get the global #GDBusProxy instance for the switcheroo-control\nsrc/shell-global.c:shell_global_get_switcheroo_control (ShellGlobal  *global)\nsrc/shell-global.c:  return global->switcheroo_control;\nsrc/shell-global.h:         shell_global_get_switcheroo_control    (ShellGlobal  *global);\n\n
Run Code Online (Sandbox Code Playgroud)\n

这证实了这一点,更直观的证明(我是 Fedora 用户):\n终端截图

\n
\n

总长DR

\n

回答你的确切问题:Gnome 通过使用库来做到这一点switcheroo-control

\n

实用的答案:你可以做同样的事情switcherooctl launch <command>

\n
\n

编辑:我不确定该命令是否适用于 ubuntu,但 debian 和 ubuntu 存储库具有 package switcheroo-control

\n

switcheroo-control这是提取的包(deb)的树。

\n
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 etc\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 dbus-1\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 system.d\n\xe2\x94\x82\xc2\xa0\xc2\xa0         \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 net.hadess.SwitcherooControl.conf\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 lib\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 systemd\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 system\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 switcheroo-control.service\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 udev\n\xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 hwdb.d\n\xe2\x94\x82\xc2\xa0\xc2\xa0         \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 30-pci-intel-gpu.hwdb\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 usr\n    \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 libexec\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 switcheroo-control\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 share\n        \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 doc\n            \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 switcheroo-control\n                \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 changelog.Debian.gz\n                \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 copyright\n                \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 NEWS.gz\n                \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 README.md\n
Run Code Online (Sandbox Code Playgroud)\n
\n

编辑:好吧,我发现了问题,在设置变量时,如果您设置为VAR=value,这是一个常规变量,同时export VAR=value可以让子进程访问它(REF)

\n

在此之后,任何一个变量都对我有用export __GLX_VENDOR_LIBRARY_NAME=nvidia,,,,,(它们有自己不同的功能export __NV_PRIME_RENDER_OFFLOAD=1export __VK_LAYER_NV_optimus=NVIDIA_onlyexport DRI_PRIME=1

\n

因此,使用switchrootctl launch <command>or 导出上述变量并启动该进程。你甚至可以创建一个别名

\n

前任:

\n

alias dgpu="export __GLX_VENDOR_LIBRARY_NAME=nvidia && export __NV_PRIME_RENDER_OFFLOAD=1 &&"

\n

进而dgpu <command>

\n

这是由 switchroot-control 设置的环境变量(在我的例子中)。\n在此输入图像描述

\n


小智 1

我不确定这是唯一的效果,但从我在笔记本电脑上找到的内容来看,它为启动的进程设置了 DRI_PRIME 环境变量。

就我而言DRI_PRIME=pci-0000_01_00_0

我真的找不到太多关于这到底如何产生影响的信息,但可以在这里找到一些信息。