Здравствуйте. Здесь я опишу свои изыски по работе Nvidia Optimus на кальке.
Если кратко - конфиг от арча для кальки. Арч Вики
Итак. Мы имеем свежеустановленную и обновленную кальку (я взял регулярку) с ядром 5.10.
Действия производились на ноутбуке Acer Aspire V5-572G с Nvidia GF 750M.
У данной модели нет возможности менять настройки видеокарт в системной bios (ака выбрать primary gpu и отключить встройку от интел), но есть оптимус, при котором физически к монитору подключается только встроенный в CPU интеловский видеоадаптер (который годен для отображения рабочего стола и ну очень легких задач.), нвидия же в нужный момент может считать сложную графику, подсовывая результат в видеопамять интела с последующим выводом на монитор.
Теперь по сути:
На свежеустановленной системе, в графической утилите кальки (раздел видео) нас встречает автоопределенный драйвер intel.
-
Используя emerge нужно установить nvidia-drivers нужной версии (у меня 460.27)
Тут стоит учесть, что для работы Vulkan нужен драйвер 435+ версии.Так же выбирать драйвер стоит не по рекомендации nvidia (мне предложили 418 версию),
а искать максимально возможный драйвер с поддержкой своей видеокарты (в пределах
разумного). -
Через консоль Calculate (раздел Видео) выбираем драйвер Nvidia (проприетарный)
-
Теперь самое интересное - Xorg
Здесь есть два варианта
3.1 Вариант первый (постоянное использование нвидии, внешне не отличается от десктопа с одной видеокартой)
lspci | grep -E “VGA|3D” нам нужен ID нвидии
/etc/X11/xorg.conf
Section “Module”
Load “modesetting”
EndSection
Section “Device”
Identifier “nvidia”
Driver “nvidia”
BusID “тут ID нвидии”
Option “AllowEmptyInitialConfiguration”
EndSection
.
Для того, чтобы утилиты кальки не затирали Ваш конфиг, нужен /etc/X11/xorg.conf.clt с таким же, как и сам xorg.conf содержанием
Так же нужна настройка менеджера входа
LightDM
Для LightDM:
/etc/lightdm/display_setup.sh
#!/bin/sh xrandr --setprovideroutputsource modesetting NVIDIA-0 xrandr --auto
Сделайте этот скрипт выполняемым:
chmod +x /etc/lightdm/display_setup.sh
Теперь настройте LightDM для запуска скрипта, отредактировав раздел [Seat:*] в /etc/lightdm/lightdm.conf:
/etc/lightdm/lightdm.conf
[Seat:*] display-setup-script=/etc/lightdm/display_setup.sh
Теперь перезагрузитесь и DM запуститься.
SDDM
/usr/share/sddm/scripts/Xsetup
xrandr --setprovideroutputsource modesetting NVIDIA-0 xrandr --auto
GDM
Для GDM создайте новый файл .desktop:
/usr/share/gdm/greeter/autostart/optimus.desktop
[Desktop Entry] Type=Application Name=Optimus Exec=sh -c “xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto” NoDisplay=true X-GNOME-Autostart-Phase=DisplayServer
Удостоверьтесь, что GDM использует X как стандартный бэкенд.
Проверка 3D
Для проверки работает ли чип Nvidia запустите:
$ glxinfo |grep NVIDIA
.
3.2 Вариант второй. PRIME Render Offload Шмель производства Nvidia
С выходом драйвера 435.21 появилась возможность использовать PRIME Render Offload
все, что до - не является предметом данного материала. Вам Nouveau или Bumblebee.
/etc/X11/xorg.conf
Section “ServerLayout”
Identifier “Layout0”
Option “AllowNVIDIAGPUScreens”
Screen 0 “iGPU” 0 0
EndSection
Section “Device”
Identifier “iGPU”
Driver “modesetting”
BusID “PCI:0:2:0” #Проверьте BusID
EndSection
Section “Device”
Identifier “dGPU”
Driver “nvidia”
BusID “PCI:1:0:0” #Проверьте BusID
EndSection
Section “Screen”
Identifier “iGPU”
Device “iGPU”
DefaultDepth 24
SubSection “Display”
Viewport 0 0
EndSubSection
EndSection
Section “OutputClass”
Identifier “iGPU”
MatchDriver “i915”
Driver “modesetting”
EndSection
Section “OutputClass”
Identifier “dGPU”
MatchDriver “nvidia-drm”
Driver “nvidia”
Option “AllowEmptyInitialConfiguration”
Option “PrimaryGPU” “yes”
EndSection
.
Для того, чтобы утилиты кальки не затирали Ваш конфиг, нужен /etc/X11/xorg.conf.clt с таким же, как и сам xorg.conf содержанием
- Reboot
5. Проверьте, что загрузились оба модуля видеокарт:
$ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x29d cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 0 name:modesetting
Provider 1: id: 0x278 cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:NVIDIA-G0
Использование
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=“nvidia” __VK_LAYER_NV_optimus=“NVIDIA_only” ПРОГРАММА
Чтобы облегчить использование длинной команды, доступен пакет prime-run. Пример использования:
$ prime-run ПРОГРАММА
Так же __GL_THREADED_OPTIMIZATIONS=1 prime-run ПРОГРАММА в некоторых случаях даст + FPS
6. Мой вариант. В целом приведенные выше конфиги работоспособны, но лично для себя я решил скрестить xorg от кальки с “типовым” конфигом.
/etc/X11/xorg.conf
#------------------------------------------------------------------------------
Modified Calculate Utilities 3.6.8.18
Processed template files:
/var/db/repos/calculate/profiles/templates/3.6/3_ac_install_live/1-merge/x11-base/xorg-server/X11/xorg.conf
For modify this file, create /etc/X11/xorg.conf.clt template.
#------------------------------------------------------------------------------
Section “ServerLayout”
Identifier “Layout 0”
Option “AllowNVIDIAGPUScreens”
Screen 0 “iGPU” 0 0
EndSection
Section “Files”
FontPath “/usr/share/fonts/corefonts”
FontPath “/usr/share/fonts/misc”
FontPath “/usr/share/fonts/droid”
EndSection
Section “Module”
Load “dbe” # Double buffer extension
Load “glx” # OpenGL X protocol interface
Load “extmod” # Misc. required extension
EndSection
Section “Monitor”
Identifier “StandardMonitor”
HorizSync 31.5 - 60.0
VertRefresh 60-160
Option “DPMS”
EndSection
Section “Device”
Identifier “iGPU”
Driver “intel”
BusID “PCI:0:2:0”
Option “AccelMethod” “glamor”
EndSection
Section “Device”
Identifier “dGPU”
Driver “nvidia”
Option “RenderAccel” “True”
Option “AllowGLXWithComposite” “True”
Option “NoLogo” “True”
Option “NvAgp” “1”
Option “DPI” “96x96”
BusID “PCI:1:0:0”
EndSection
Section “Screen”
Identifier “iGPU”
Device “iGPU”
Monitor “StandardMonitor”
DefaultDepth 24
Subsection “Display”
Viewport 0 0
Depth 24
Modes “1366x768”
EndSubsection
EndSection
Section “OutputClass”
Identifier “iGPU”
MatchDriver “i915”
Driver “modesetting”
EndSection
Section “OutputClass”
Identifier “dGPU”
MatchDriver “nvidia-drm”
Driver “nvidia”
Option “AllowEmptyInitialConfiguration”
Option “PrimaryGPU” “yes”
EndSection
Section “Extensions”
Option “Composite” “On”
EndSection
/etc/X11/xorg.conf.clt
#------------------------------------------------------------------------------
Modified Calculate Utilities 3.6.8.18
Processed template files:
/var/db/repos/calculate/profiles/templates/3.6/3_ac_install_live/1-merge/x11-base/xorg-server/X11/xorg.conf
For modify this file, create /etc/X11/xorg.conf.clt template.
#------------------------------------------------------------------------------
Section “ServerLayout”
Identifier “Layout 0”
Option “AllowNVIDIAGPUScreens”
Screen 0 “iGPU” 0 0
EndSection
Section “Files”
FontPath “/usr/share/fonts/corefonts”
FontPath “/usr/share/fonts/misc”
FontPath “/usr/share/fonts/droid”
EndSection
Section “Module”
Load “dbe” # Double buffer extension
Load “glx” # OpenGL X protocol interface
Load “extmod” # Misc. required extension
EndSection
Section “Monitor”
Identifier “StandardMonitor”
HorizSync 31.5 - 60.0
VertRefresh 60-160
Option “DPMS”
EndSection
Section “Device”
Identifier “iGPU”
Driver “intel”
BusID “PCI:0:2:0”
Option “AccelMethod” “glamor”
EndSection
Section “Device”
Identifier “dGPU”
Driver “nvidia”
Option “RenderAccel” “True”
Option “AllowGLXWithComposite” “True”
Option “NoLogo” “True”
Option “NvAgp” “1”
Option “DPI” “96x96”
BusID “PCI:1:0:0”
EndSection
Section “Screen”
Identifier “iGPU”
Device “iGPU”
Monitor “StandardMonitor”
DefaultDepth 24
Subsection “Display”
Viewport 0 0
Depth 24
Modes “1366x768”
EndSubsection
EndSection
Section “OutputClass”
Identifier “iGPU”
MatchDriver “i915”
Driver “modesetting”
EndSection
Section “OutputClass”
Identifier “dGPU”
MatchDriver “nvidia-drm”
Driver “nvidia”
Option “AllowEmptyInitialConfiguration”
Option “PrimaryGPU” “yes”
EndSection
Section “Extensions”
Option “Composite” “On”
EndSection
.
Если решите использовать, проверьте разрешение, DPI. В моих конфигах - мои значения. Так же у меня modesettings работает так себе, я использовал гламур.
Подробнее можно почитать в первоисточнике, на Арч Вики. Там же есть еще варианты настройки, типовые проблемы и их решения.