ECK
Back to Blog
3 min read

Surviving NVIDIA Optimus on Linux: A Practical Guide

How to configure hybrid graphics (NVIDIA + Intel/AMD) on Linux without losing your sanity. Covers PRIME, envycontrol, and power management.

linuxnvidiagpuconfiguration

Surviving NVIDIA Optimus on Linux: A Practical Guide

If you've ever tried to use a laptop with NVIDIA Optimus on Linux, you know the pain. Hybrid graphics — where an integrated GPU handles basic tasks and a discrete NVIDIA GPU handles heavy workloads — is one of those things that "just works" on Windows but requires significant effort on Linux.

This guide distills what I've learned (and what I built into envytui) into a practical reference.

Understanding the Architecture

NVIDIA Optimus laptops have two GPUs:

  • iGPU (Intel/AMD): Low power, handles desktop rendering
  • dGPU (NVIDIA): High performance, activated for demanding tasks

The challenge is routing rendering between them. On Linux, three main approaches exist:

1. PRIME Offloading (Recommended)

The modern approach. The iGPU drives the display, and you selectively offload applications to the dGPU:

# Run an application on the NVIDIA GPU
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia ./my_application

# Shorthand with prime-run (if available)
prime-run ./my_application

Pros: Best power management, seamless switching Cons: Slight overhead from buffer copying

2. Reverse PRIME

The dGPU renders everything and sends output to the iGPU's display:

xrandr --setprovideroutputsource NVIDIA-G0 modesetting
xrandr --auto

Pros: Maximum performance Cons: The dGPU is always on, destroying battery life

3. Full GPU Switching

Completely disable one GPU and use the other exclusively. This is what envycontrol manages:

# Using envycontrol
envycontrol -s integrated  # NVIDIA off, maximum battery
envycontrol -s hybrid      # PRIME offload mode
envycontrol -s nvidia      # Full NVIDIA mode

Driver Installation

On Arch Linux (my daily driver):

# Proprietary drivers (recommended for Optimus)
sudo pacman -S nvidia nvidia-utils nvidia-settings

# For the latest kernels
sudo pacman -S nvidia-dkms

# 32-bit support (for Steam/Wine)
sudo pacman -S lib32-nvidia-utils

Critical configuration in /etc/modprobe.d/nvidia.conf:

options nvidia_drm modeset=1
options nvidia NVreg_DynamicPowerManagement=0x02

The NVreg_DynamicPowerManagement=0x02 enables fine-grained power management (Turing+ GPUs), letting the dGPU fully power off when idle.

Common Issues and Fixes

Black Screen After Login

Usually caused by conflicting display managers or missing DRM kernel mode setting:

# Ensure nvidia-drm is loaded early
# In /etc/mkinitcpio.conf, add to MODULES:
MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

# Rebuild initramfs
sudo mkinitcpio -P

Screen Tearing

Add to /etc/X11/xorg.conf.d/20-nvidia.conf:

Section "Device"
    Identifier "NVIDIA"
    Driver "nvidia"
    Option "ForceFullCompositionPipeline" "on"
EndSection

Or on Wayland, this is handled automatically with the DRM modeset option.

Suspend/Resume Failures

NVIDIA's power management services are essential:

sudo systemctl enable nvidia-suspend.service
sudo systemctl enable nvidia-resume.service
sudo systemctl enable nvidia-hibernate.service

Power Monitoring

Check which GPU is active:

# Check NVIDIA GPU status
cat /sys/bus/pci/devices/0000:01:00.0/power/runtime_status
# "suspended" = powered off, "active" = running

# Monitor power draw
nvidia-smi -q -d POWER

Why I Built envytui

After configuring Optimus on multiple machines, I got tired of remembering all the steps. envytui provides a terminal UI for managing GPU modes — it wraps envycontrol and adds a user-friendly interface for switching between integrated, hybrid, and NVIDIA modes.

Conclusion

NVIDIA Optimus on Linux has improved significantly in recent years, especially with PRIME offloading and fine-grained power management. The key is getting the initial setup right: proper drivers, DRM modeset enabled, and power management configured. Once that's in place, it's surprisingly stable.