Skip to content

Instantly share code, notes, and snippets.

@gabrielsond
Last active December 21, 2021 00:02
Show Gist options
  • Save gabrielsond/03915dfcba8dceee4165a6ace6474ede to your computer and use it in GitHub Desktop.
Save gabrielsond/03915dfcba8dceee4165a6ace6474ede to your computer and use it in GitHub Desktop.
X.org Configured for Intel (mode-setting) Graphics and NVIDIA (2x GPU) Compute
# The purpose of this configuration is to use an integrated Intel GPU for Xorg graphical display while using NVIDIA GPU(s)
# for compute applications (NOT for actual display in Xorg).
#
# The use case for this configuration is enabling a desktop system to fully function with basic hardware acceleration while
# retaining FULL processing power from discrete GPU(s) for mining, video encoding, etc. In order to enable FULL processing
# power of NVIDIA, nvidia-settings must be used to make overclocking adjustments.
#
# This has been tested with Intel® UHD Graphics 750 (Intel® Core™ i5-11700K Processor) and two
# MSI VENTUS GeForce RTX™ 3060 2X 12G OC LHR (https://www.techpowerup.com/gpu-specs/msi-rtx-3060-ventus-2x-oc-lhr.b9132)
#
# Additionally, you DO NOT need more monitor sections for multiple monitors connected to the Intel GPU. I use dual monitors.
#
# Useful resources
# ----------------
# http://litaotju.github.io/2019/03/13/=Use-intel-for-display-nvidia-for-computing/
# https://gist.github.com/wangruohui/bc7b9f424e3d5deb0c0b8bba990b1bc5
#
# This is hand modified mixture of the output from the following commands:
# - nvidia-xconfig --cool-bits=31 --allow-empty-initial-configuration --virtual=1920x1080 --enable-all-gpus --separate-x-screens -o /tmp/xorg.conf
# - Xorg :0 -configure
#
# In order to use nvidia-settings, the NVIDIA GPU(s) use a small amount of GPU memory to create unused virtual display(s):
# $ nvtop
# PID USER DEV TYPE GPU GPU MEM CPU HOST MEM
# 486 root 0 Graphic 0% 5MiB 0% 0% 114MiB /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
# 486 root 1 Graphic 0% 5MiB 0% 0% 114MiB /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
#
# Identifier Naming
# -----------------
# Intel:
# Device: "Integrated"
# Screen: "PrimaryScreen"
# Monitor: "PrimaryMonitor"
# NVIDIA 1:
# Device: "nvidia0"
# Screen: "VirtualScreen0"
# Monitor: "VirtualMonitor0"
# NVIDIA 2:
# Device: "nvidia1"
# Screen: "VirtualScreen1"
# Monitor: "VirtualMonitor1"
Section "ServerLayout"
Identifier "X.org Configured for Intel (modesetting) Graphics and NVIDIA Compute"
Screen 0 "PrimaryScreen" 0 0
Screen 1 "VirtualScreen0" RightOf "PrimaryScreen"
Screen 2 "VirtualScreen1" RightOf "VirtualScreen0" # remove this line if using single NVIDIA GPU
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/lib/xorg/modules"
FontPath "/usr/share/fonts/misc"
FontPath "/usr/share/fonts/TTF"
FontPath "/usr/share/fonts/OTF"
FontPath "/usr/share/fonts/Type1"
FontPath "/usr/share/fonts/100dpi"
FontPath "/usr/share/fonts/75dpi"
EndSection
Section "Module"
Load "glx"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5 6 7"
EndSection
# Monitor for integrated Intel GPU
Section "Monitor"
Identifier "PrimaryMonitor"
EndSection
# (Virtual) Monitor for NVIDIA GPU 1
Section "Monitor"
Identifier "VirtualMonitor0"
EndSection
# remove the following section if using single NVIDIA GPU
# (Virtual) Monitor for NVIDIA GPU 2
Section "Monitor"
Identifier "VirtualMonitor1"
EndSection
# Device for integrated Intel GPU (modern integrated Intel GPUs should using 'modesetting' driver, NOT 'i915', i915 will be loaded anyway)
Section "Device"
Identifier "Integrated"
Driver "modesetting"
BusID "PCI:0:2:0"
EndSection
# Device for NVIDIA GPU 1
Section "Device"
Identifier "nvidia0"
Driver "nvidia"
BusID "PCI:1:0:0"
EndSection
# remove the following section if using single NVIDIA GPU
# Device for NVIDIA GPU 2
Section "Device"
Identifier "nvidia1"
Driver "nvidia"
BusID "PCI:2:0:0"
EndSection
# Screen for integrated Intel GPU
Section "Screen"
Identifier "PrimaryScreen"
Device "Integrated"
Monitor "PrimaryMonitor"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection
# (Virtual) Screen for NVIDIA GPU 1
Section "Screen"
Identifier "VirtualScreen0"
Device "nvidia0"
Monitor "VirtualMonitor0"
Option "AllowEmptyInitialConfiguration" "True"
Option "UseDisplayDevice" "None"
Option "Coolbits" "31" # enable all features
# create the most minimal virtual display possible
DefaultDepth 8
SubSection "Display"
Virtual 304 200
Depth 8
EndSubSection
EndSection
# remove the following section if using single NVIDIA GPU
# (Virtual) Screen for NVIDIA GPU 2
Section "Screen"
Identifier "VirtualScreen1"
Device "nvidia1"
Monitor "VirtualMonitor1"
Option "AllowEmptyInitialConfiguration" "True"
Option "UseDisplayDevice" "None"
Option "Coolbits" "31" # enable all features
# create the most minimal virtual display possible
DefaultDepth 8
SubSection "Display"
Virtual 304 200
Depth 8
EndSubSection
EndSection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment