iGPU for Hyprland, Nvidia for ML tasks

Published on

tldr; don’t use the GPU for Linux, but only for ML training

The eternal struggle with Linux and Nvidia continues. Installing Arch and Nvidia worked surprisingly well, but when I started Hyprland, it stopped booting:

pasted-image-20250918145229

To get it to boot, I had to disable nvidia in the systemd-boot. Press e and append this:

modprobe.blacklist=nvidia,nvidia_drm,nvidia_modeset,nvidia_uvm

Not it boots without Nvidia. Make it permanent by

$ cat /etc/modprobe.d/blacklist-nvidia.conf
blacklist nvidia
blacklist nvidia_drm
blacklist nvidia_modeset
blacklist nvidia_uvm

$ sudo mkinitcpio -P

Rebooting works now and Nvidia is disabled. Wayland does not work properly with Nvidia. But I don’t care. I even like it to have the GPU for training only.

To offload work to Nvidia in Python, enable the kernel modules:

sudo modprobe nvidia nvidia_drm nvidia_modeset nvidia_uvm

nvidia-smi

In a .venv, install PyTroch (11/2025, see here for updated command, 1-2 GB download):

pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126

Make offloading automatic, add this to .zshrc:

sudo pacman -S nvidia-prime

echo 'alias prime-run="__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only"' >> ~/.zshrc

prime-run python train.py

I aliased python to p, so I can also do:

echo 'alias p="__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only python3"' >> ~/.zshrc

p train.py

Now run

import torch
print(torch.cuda.is_available())  # should be True