sodcalculator

10 Tech How-To

NVIDIA Optimus on Linux: Step-by-Step Setup Guide

Guide 10-49504 · Updated · Step by step

NVIDIA Optimus switches between integrated Intel/AMD graphics and the discrete NVIDIA GPU to save power, but on Linux it needs manual configuration to work reliably. This guide walks you through installing the proper drivers and setting up a working Optimus system, covering both NVIDIA’s official solution and the open-source alternative.

What You’ll Need

  • A laptop with NVIDIA Optimus (Intel or AMD integrated GPU + NVIDIA discrete GPU)
  • A supported Linux distribution (Ubuntu, Fedora, Arch, etc.)
  • Internet connection to download drivers
  • Basic familiarity with the terminal and sudo commands
  • NVIDIA driver version 435.17 or newer (for NVIDIA’s official Optimus support)

Step-by-Step

  1. Identify your GPUs and current driver state. Run lspci | grep -E "VGA|3D" to see both GPUs. Check if NVIDIA drivers are already installed with nvidia-smi (if it shows driver info, you’re already partway there).
  2. Update your system and kernel. Run sudo apt update && sudo apt upgrade (Debian/Ubuntu) or the equivalent for your distro. A recent kernel is required for the best Optimus support.
  3. Install the NVIDIA driver via your distro’s package manager. On Ubuntu, use sudo ubuntu-drivers autoinstall or sudo apt install nvidia-driver-550 (replace with the latest available). On Fedora: sudo dnf install akmod-nvidia. On Arch: sudo pacman -S nvidia nvidia-utils. Avoid downloading from NVIDIA’s website if possible—distro packages handle kernel updates better.
  4. Reboot. After installation, reboot to load the NVIDIA kernel module. Verify with nvidia-smi—it should list your GPU and driver version.
  5. Install the Optimus manager. NVIDIA’s official solution is nvidia-prime (available on Ubuntu and some others). Install it with sudo apt install nvidia-prime. For more control, consider optimus-manager (Arch, Fedora, and others) or envycontrol (Debian/Ubuntu).
  6. Choose your GPU mode. With nvidia-prime, you can switch between nvidia (discrete only) and on-demand (hybrid) via sudo prime-select. For example, sudo prime-select on-demand enables Optimus. With optimus-manager, use optimus-manager --switch hybrid and reboot.
  7. Configure PRIME render offload (for hybrid mode). If you chose on-demand/hybrid, set the environment variable to run applications on the NVIDIA GPU. For example, __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep "OpenGL renderer" should show the NVIDIA GPU. To make it permanent for specific apps, create a .desktop file or use prime-run (available in nvidia-prime) to launch apps: prime-run steam.
  8. Test with a game or benchmark. Run glxgears or a game with prime-run and check the FPS. Also check nvidia-smi while the app runs to confirm the GPU is being used.
  9. Set up power management (optional). For better battery life, enable the NVIDIA suspend service: sudo systemctl enable nvidia-suspend and related services. On some systems, you may need to add nvidia-drm.modeset=1 to kernel parameters for proper runtime power management.
  10. Configure Xorg for Optimus (if needed). If you’re not using a display manager that handles this automatically, create /etc/X11/xorg.conf.d/10-optimus.conf with the appropriate ServerLayout and Device sections. Most modern distros do this automatically, so only do this if you’re having issues.

Common Mistakes

  • Installing drivers from NVIDIA’s website instead of using your distro’s packages—this often breaks after kernel updates.
  • Using the wrong prime-select mode. Setting nvidia mode disables the integrated GPU entirely, which kills battery life. Use on-demand for hybrid.
  • Forgetting to reboot after driver installation—the NVIDIA module won’t load until then.
  • Not setting the PRIME render offload variables—without them, apps run on the Intel GPU even in hybrid mode.
  • Using an outdated kernel that lacks support for the latest NVIDIA driver.

Tips

  • Use prime-run to launch applications that need the NVIDIA GPU—it sets all the necessary variables automatically.
  • For gaming, consider using gamemode and mangohud to optimize performance and monitor GPU usage.
  • If you’re on a laptop with an AMD integrated GPU, the same steps apply, but you may need to use amdgpu kernel module settings.
  • Keep your system updated—NVIDIA and distro maintainers regularly improve Optimus support.
  • For Wayland sessions, use nvidia-drm.modeset=1 and consider using nvidia-prime with the on-demand mode, as it works better with Wayland.

Troubleshooting

  • No NVIDIA GPU detected after install. Run sudo modprobe nvidia and check dmesg | grep nvidia. If there are errors, reinstall the driver and ensure Secure Boot is disabled or signed modules are used.
  • Screen flickering or black screen on boot. Try adding nomodeset to kernel parameters temporarily. If that helps, adjust your Xorg configuration or use the nvidia mode instead of hybrid.
  • Apps don’t use the NVIDIA GPU even with prime-run. Verify the NVIDIA module is loaded (lsmod | grep nvidia) and check that the application is not using Vulkan—for Vulkan, you need __VK_LAYER_NV_optimus=NVIDIA_only as well.
  • Battery drains fast. Ensure you’re in hybrid mode, not nvidia-only. Also check that the NVIDIA GPU is actually powering down when idle (cat /proc/driver/nvidia/gpus/*/power).
  • System freezes after suspend. Enable the NVIDIA suspend services and add nvidia-drm.modeset=1 to kernel parameters. If it persists, try the nvidia mode instead.
  • External monitor not working. In hybrid mode, external displays are usually driven by the NVIDIA GPU. Try switching to nvidia mode temporarily to see if it’s a driver issue.

Frequently Asked Questions

Q: Can I use NVIDIA Optimus on Linux without proprietary drivers?
A: Yes, the open-source Nouveau driver supports basic Optimus, but performance is poor and power management is limited. For gaming, proprietary drivers are recommended.

Q: What is the difference between ‘nvidia’ and ‘on-demand’ modes?
A: ‘nvidia’ mode uses the discrete GPU for everything, draining battery. ‘on-demand’ keeps the integrated GPU as default and only uses NVIDIA when requested via prime-run.

Q: Will Optimus work with Wayland?
A: Yes, with recent NVIDIA drivers (515+) and the on-demand mode, Wayland works well. Some older apps may have issues, but most modern ones are fine.

Q: How do I set a specific application to always use the NVIDIA GPU?
A: Create a .desktop file with the Exec line prefixed by prime-run, or use environment variables in the app’s launch script.

Q: Do I need to reinstall drivers after every kernel update?
A: If you use distro packages, no—they automatically rebuild the kernel module. If you installed manually, yes, you’ll need to reinstall.

Q: Why is my external monitor not detected?
A: In hybrid mode, external displays are often connected to the NVIDIA GPU. Try switching to nvidia-only mode, or check your Xorg configuration for the correct output.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →