
How to Set the Primary GPU on Linux Systems with Multiple GPUs
1. Check Your GPUs
First, verify which GPUs are available on your system:
lspci | grep -E "VGA|3D"
You’ll see entries like:
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630
01:00.0 VGA compatible controller: NVIDIA Corporation TU106 [GeForce RTX 2060]
This shows you have both Intel and NVIDIA GPUs.
2. Identify GPU Drivers
Run the following command to check which drivers are in use:
lshw -C display
or
glxinfo | grep "OpenGL renderer"
Ensure the proper drivers are installed (for example, nvidia-driver-###
for NVIDIA or amdgpu
for AMD).
3. Set the Primary GPU via BIOS
If you want the dedicated GPU to always be the primary one for boot and display:
- Reboot and enter your BIOS/UEFI (usually by pressing F2, DEL, or ESC).
- Look for Primary Display, Init Display First, or Graphics Configuration.
- Select PCIe (for discrete GPU) or iGPU (for integrated graphics).
- Save and exit.
This method is system-wide and applies before Linux boots.
4. Set the Primary GPU in Xorg (Linux GUI)
If you want to control the primary GPU in your desktop session:
- Create or edit your Xorg configuration file:
sudo nano /etc/X11/xorg.conf
- Add a section like:
Section "Device" Identifier "NVIDIA Card" Driver "nvidia" BusID "PCI:1:0:0" EndSection
You can find your
BusID
using:lspci | grep -E "VGA|3D"
- Save and reboot.
5. Use Environment Variables (For Specific Apps)
If you only want certain applications to use the dedicated GPU, you can use environment variables:
- For NVIDIA Optimus systems:
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia <application>
- For AMD switchable graphics:
DRI_PRIME=1 <application>
This way, you can selectively run apps on your preferred GPU.
6. Verify the Active GPU
To confirm which GPU is active:
nvidia-smi
or
glxinfo | grep "OpenGL renderer"
How to Set the Primary GPU on Linux Systems with Multiple GPUs
(F.A.Q)
How can I check if my system supports GPU switching?
Use lspci
and lshw -C display
to see if multiple GPUs are detected. Hybrid laptops usually support this feature.
Does Wayland support GPU switching?
Support for GPU switching on Wayland is improving but still varies by distribution and driver.
Can I switch GPUs without rebooting?
Yes, you can use DRI_PRIME
or NVIDIA’s PRIME render offload for runtime switching.
What’s the safest method for beginners?
Setting the GPU through the BIOS is the safest and most reliable method for beginners.