Skip to content

Instantly share code, notes, and snippets.

@bmcbm
Last active May 21, 2025 10:22
Show Gist options
  • Save bmcbm/375f14eaa17f88756b4bdbbebbcfd029 to your computer and use it in GitHub Desktop.
Save bmcbm/375f14eaa17f88756b4bdbbebbcfd029 to your computer and use it in GitHub Desktop.
NVIDIA Suspend fix
# Use systemd for managing NVIDIA driver suspend in drivers ====>>> PRIOR to version 470 <<<=====
# https://download.nvidia.com/XFree86/Linux-x86_64/450.66/README/powermanagement.html
# https://forums.developer.nvidia.com/t/unable-to-set-nvidia-kernel-module-parameters/161306
# Please note: In Fedora Linux you may need to just install the xorg-x11-drv-nvidia-power pakage
# as sugested by @goombah88 in the comments below.
TMP_PATH=/var/tmp
TMPL_PATH=/usr/share/doc/nvidia-driver-460/
echo "options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=${TMP_PATH}" | sudo tee /etc/modprobe.d/nvidia-power-management.conf
sudo install --mode 644 "${TMPL_PATH}/nvidia-suspend.service" /etc/systemd/system
sudo install --mode 644 "${TMPL_PATH}/nvidia-hibernate.service" /etc/systemd/system
sudo install --mode 644 "${TMPL_PATH}/nvidia-resume.service" /etc/systemd/system
sudo install "${TMPL_PATH}/nvidia" /lib/systemd/system-sleep
sudo install "${TMPL_PATH}/nvidia-sleep.sh" /usr/bin
sudo systemctl enable nvidia-suspend.service
sudo systemctl enable nvidia-hibernate.service
sudo systemctl enable nvidia-resume.service
@pgbarletta
Copy link

sudo systemctl unmask nvidia-suspend
sudo systemctl enable nvidia-suspend
sudo systemctl unmask nvidia-resume
sudo systemctl enable nvidia-resume
sudo systemctl unmask nvidia-hibernate
sudo systemctl enable nvidia-hibernate

Thanks! It worked on a Lenovo P1G7 with kubuntu 24.04 and Driver Version: 570.124.06 CUDA Version: 12.8

@misterBart
Copy link

sudo systemctl unmask nvidia-suspend
sudo systemctl enable nvidia-suspend
sudo systemctl unmask nvidia-resume
sudo systemctl enable nvidia-resume
sudo systemctl unmask nvidia-hibernate
sudo systemctl enable nvidia-hibernate

Did not work for me. Using Ubuntu 24.10 and nvidia-driver-560.

As for the responses of tommyliu and pgbarletta, I am unsure whether they are helpful, because they are using driver 570, and the problem has been fixed starting from driver 565 according to ethan2009.

Also the disabling of the services and the editing of nvidia-sleep.sh suggested by bilallamal07 did not work for me.

Ubuntu 24.10 did allow me to choose the nvidia-driver-570-server, which solved the problem, probably because it contains the fix starting from driver 565.

@ahmed-aly-aut
Copy link

For me on driver 535.216.03 and GeForce RTX 2070 Mobile / Max-Q the following services where located under /usr/lib/systemd/system/:

  • nvidia-hibernate.service
  • nvidia-persistenced.service
  • nvidia-resume.service
  • nvidia-suspend.service

This meant taht I only had to enable them with

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

@leber006
Copy link

This is my current setting and it's working for me (Linux Mint 22, Nvidia GeForce GTX 745 using Nvidia 550.107.02 driver)

sudo nano /etc/modprobe.d/nvidia-graphics-drivers-kms.conf

and add these lines into it:

options nvidia-drm fbdev=1 options nvidia NVreg_PreserveVideoMemoryAllocations=1 options nvidia NVreg_TemporaryFilePath=/var/tmp

This fixed my issues!
Laptop: Lenovo p16v Gen 1
System:
Kubuntu 24.04.2 LTS, noble
AMD Ryzen 7 7840HS w/ Radeon 780M Graphics
Nvidia rtx A500: Driver 570.133.07
Kernel: 6.11.0-24-generic

(Issue remaining: "unable to change power state from D3hot to D0")

I also tried the answer from dmikushin, but it didn't change anything!

sudo systemctl unmask nvidia-suspend
sudo systemctl enable nvidia-suspend
sudo systemctl unmask nvidia-resume
sudo systemctl enable nvidia-resume
sudo systemctl unmask nvidia-hibernate
sudo systemctl enable nvidia-hibernate

@Perkolator
Copy link

Perkolator commented May 8, 2025

As for the responses of tommyliu and pgbarletta, I am unsure whether they are helpful, because they are using driver 570, and the problem has been fixed starting from driver 565 according to ethan2009.

It's not fixed in 570 branch. People still have this problem on 570. Few days ago I upgraded from 535.183.01 to 570.133.07 and was hit with this problem for the first time. Hibernate seems to work ok though, it's sleep/suspend that gives the error/problem. EDIT: Hibernate stopped also working. Downgraded to 535.230.02 and everything works again. Nvidia still has way too many problems in linux.

@berkaykrc
Copy link

I'm losing my mind and time with this problem on

  • Fedora 42 kernel 6.14.5-300.fc42.x86_64
  • 570.144 drivers.

@gdim47
Copy link

gdim47 commented May 20, 2025

I found solution for my system, tested with nvidia driver 570.153.02.
To get suspend/hibernation working correctly i had to change my kernel version to 6.13.7 and set NVreg_EnableGpuFirmware to 0 for nvidia kernel module.
With other kernel versions(i tested 6.12.29 lts and mainline 6.14.6) i get a black screen when trying to resume from suspend/hibernate1.

Here is modprobe.d config for nvidia module(/etc/modprobe.d/nvidia.conf):

options nvidia NVreg_PreserveVideoMemoryAllocations=1
options nvidia NVreg_TemporaryFilePath=/var/tmp
options nvidia NVreg_EnableGpuFirmware=0

Enabled nvidia systemd services:

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

My system:

  • Lenovo Legion R7000 AHP9
  • AMD Ryzen 7 8745H
  • 32 GB ram
  • Video: Nvidia RTX 4050(dGPU) + AMD Radeon 780M(iGPU)
  • OS: Fedora 41, KDE 6.3.5 with Kwin wayland session
  • Nvidia driver version: 570.153.02

Footnotes

  1. As workaround I found that with magic SysRq request for SIGTERM to all processes, i can bypass/kill hanged nvidia(?) scripts. Keyboard shortcut: Alt+SysRq(PrtSc)+e

@Perkolator
Copy link

FYI, there's a new systemd service for newer nvidia driver versions. So if someone uses suspend-then-hibernate on their system, you might need to enable that too for nvidia:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment