Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@yingtanairbussv
Copy link

@bmharper That works for alienware laptop with nvidia driver 515

@yingtanairbussv
Copy link

It works. The power drain I see before is not related to nvidia graphic card.

I tried to put the alienware laptop to airplane mode and pull out usb dondle before put into suspend, and put in the backpack for the whole night. The battery level only down by 9% which is normal, and no extra heat in the backpack.

@yingtanairbussv
Copy link

BTW: I also update the driver to version 520, and upgrade ubuntu to 22.04.1 LTS. Works fine.

@sbwcwso
Copy link

sbwcwso commented Oct 28, 2022

sudo rm /etc/systemd/system/systemd-hibernate.service.requires/nvidia-resume.service
sudo rm /etc/systemd/system/systemd-hibernate.service.requires/nvidia-hibernate.service
sudo rm /etc/systemd/system/systemd-suspend.service.requires/nvidia-resume.service
sudo rm /etc/systemd/system/systemd-suspend.service.requires/nvidia-suspend.service

worked for me. Thank you very much.

@mtz29
Copy link

mtz29 commented Jan 14, 2023

For me, with nvidia-driver-495, the simple solution was to remove the damaged symlinks from systemd. You most likely have them if you upgraded from nvidia-driver-470, because 470 still included the .service files in /lib/systemd/system/. The files are no longer included in 495 but the postinst script does not remove the symlinks. So, remove them with:

sudo rm /etc/systemd/system/systemd-hibernate.service.requires/nvidia-resume.service
sudo rm /etc/systemd/system/systemd-hibernate.service.requires/nvidia-hibernate.service
sudo rm /etc/systemd/system/systemd-suspend.service.requires/nvidia-resume.service
sudo rm /etc/systemd/system/systemd-suspend.service.requires/nvidia-suspend.service

Works instantly, no need of rebooting or logging off.

This does the job. Thank you.

@kolubex
Copy link

kolubex commented Feb 16, 2023

sudo rm /etc/systemd/system/systemd-hibernate.service.requires/nvidia-resume.service
sudo rm /etc/systemd/system/systemd-hibernate.service.requires/nvidia-hibernate.service
sudo rm /etc/systemd/system/systemd-suspend.service.requires/nvidia-resume.service
sudo rm /etc/systemd/system/systemd-suspend.service.requires/nvidia-suspend.service

Thank you, This worked in my case.

@ermenkov
Copy link

ermenkov commented Mar 8, 2023

The method works. In case you need fresh files install the services, you can get your driver version from NVIDIA. Use nvidia-smi to get the exact version and then run the .run file with --extract-only flag: sudo bash NVIDIA-Linux-x86_64-515.65.01.run --extract-only.

Then you run the given commands setting the TMPL_PATH to the path where you've extracted the files. Keep in mind that the files for this driver (515.65.01) have a slightly different locations as stated in the original post. So the updated commands should be like this:

TMPL_PATH=/home/user/Downloads/NVIDIA-Linux-x86_64-515.65.01/systemd

sudo install --mode 644 "${TMPL_PATH}/system/nvidia-suspend.service" /etc/systemd/system
sudo install --mode 644 "${TMPL_PATH}/system/nvidia-hibernate.service" /etc/systemd/system
sudo install --mode 644 "${TMPL_PATH}/system/nvidia-resume.service" /etc/systemd/system
sudo install "${TMPL_PATH}/system-sleep/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

@neufr-docker
Copy link

Thanks! This worked for me for 530.30.02

@gruentee
Copy link

Thanks! This worked for me for 530.30.02

Having troubles to understand what exactly worked for you - enabling or removing the service files? Comments here seem to suggest contradicting solutions.

@392781
Copy link

392781 commented Apr 15, 2023

Thanks! This worked for me for 530.30.02

Having troubles to understand what exactly worked for you - enabling or removing the service files? Comments here seem to suggest contradicting solutions.

Removing. If the symlinks are broken, best you can do is remove.

@Sahas-Ananth
Copy link

Thanks! This worked for me for 530.30.02

I have tried removing too. Driver: 530.41.03. I have been working on this for hours I have 0 clues on how to fix this issue. Just for clarity, When I do sudo systemctl suspend it kinda just logs out and does not enter suspend. Although Initially, I did have a problem where it would just hang when I wake from suspend.

This is what it throws out when I run journalctl -b | grep suspend. Somebody help 😭

May 03 17:57:26 Dennis-Ritchie kernel: nvme 0000:03:00.0: platform quirk: setting simple suspend
May 03 17:57:26 Dennis-Ritchie systemd-udevd[3535]: suspend: Process '/bin/chgrp video /sys/class/backlight/nvidia_0/brightness' failed with exit code 1.
May 03 17:57:26 Dennis-Ritchie systemd-udevd[3535]: suspend: Process '/bin/chmod g+w /sys/class/backlight/nvidia_0/brightness' failed with exit code 1.
May 03 18:21:05 Dennis-Ritchie ModemManager[8316]: <info>  [sleep-monitor] system is about to suspend
May 03 18:21:08 Dennis-Ritchie kernel: PM: suspend entry (deep)
May 03 18:21:12 Dennis-Ritchie kernel: printk: Suspending console(s) (use no_console_suspend to debug)
May 03 18:21:12 Dennis-Ritchie kernel: NVRM: GPU 0000:01:00.0: PreserveVideoMemoryAllocations module parameter is set. System Power Management attempted without driver procfs suspend interface. Please refer to the 'Configuring Power Management Support' section in the driver README.
May 03 18:21:12 Dennis-Ritchie kernel: PM: pci_pm_suspend(): nv_pmops_suspend+0x0/0x30 [nvidia] returns -5
May 03 18:21:12 Dennis-Ritchie kernel: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1b0 returns -5
May 03 18:21:12 Dennis-Ritchie kernel: nvidia 0000:01:00.0: PM: failed to suspend async: error -5
May 03 18:21:12 Dennis-Ritchie kernel: PM: Some devices failed to suspend, or early wake event detected
May 03 18:21:12 Dennis-Ritchie kernel: PM: suspend exit
May 03 18:21:12 Dennis-Ritchie kernel: PM: suspend entry (s2idle)
May 03 18:21:13 Dennis-Ritchie kernel: printk: Suspending console(s) (use no_console_suspend to debug)
May 03 18:21:13 Dennis-Ritchie kernel: NVRM: GPU 0000:01:00.0: PreserveVideoMemoryAllocations module parameter is set. System Power Management attempted without driver procfs suspend interface. Please refer to the 'Configuring Power Management Support' section in the driver README.
May 03 18:21:13 Dennis-Ritchie kernel: PM: pci_pm_suspend(): nv_pmops_suspend+0x0/0x30 [nvidia] returns -5
May 03 18:21:13 Dennis-Ritchie kernel: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1b0 returns -5
May 03 18:21:13 Dennis-Ritchie kernel: nvidia 0000:01:00.0: PM: failed to suspend async: error -5
May 03 18:21:13 Dennis-Ritchie kernel: PM: Some devices failed to suspend, or early wake event detected
May 03 18:21:13 Dennis-Ritchie systemd-sleep[29540]: Failed to suspend system. System resumed again: Input/output error
May 03 18:21:13 Dennis-Ritchie kernel: PM: suspend exit
May 03 18:21:13 Dennis-Ritchie systemd[1]: systemd-suspend.service: Main process exited, code=exited, status=1/FAILURE
May 03 18:21:13 Dennis-Ritchie systemd[1]: systemd-suspend.service: Failed with result 'exit-code'.
May 03 18:21:13 Dennis-Ritchie systemd[1]: suspend.target: Job suspend.target/start failed with result 'dependency'.
May 03 18:21:38 Dennis-Ritchie sudo[30366]:    sahas : TTY=pts/0 ; PWD=/home/sahas ; USER=root ; COMMAND=/usr/bin/systemctl suspend
May 03 18:21:38 Dennis-Ritchie ModemManager[8316]: <info>  [sleep-monitor] system is about to suspend
May 03 18:21:43 Dennis-Ritchie kernel: PM: suspend entry (deep)
May 03 18:21:48 Dennis-Ritchie kernel: printk: Suspending console(s) (use no_console_suspend to debug)
May 03 18:21:48 Dennis-Ritchie kernel: NVRM: GPU 0000:01:00.0: PreserveVideoMemoryAllocations module parameter is set. System Power Management attempted without driver procfs suspend interface. Please refer to the 'Configuring Power Management Support' section in the driver README.
May 03 18:21:48 Dennis-Ritchie kernel: PM: pci_pm_suspend(): nv_pmops_suspend+0x0/0x30 [nvidia] returns -5
May 03 18:21:48 Dennis-Ritchie kernel: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1b0 returns -5
May 03 18:21:48 Dennis-Ritchie kernel: nvidia 0000:01:00.0: PM: failed to suspend async: error -5
May 03 18:21:48 Dennis-Ritchie kernel: PM: Some devices failed to suspend, or early wake event detected
May 03 18:21:48 Dennis-Ritchie kernel: PM: suspend exit
May 03 18:21:48 Dennis-Ritchie kernel: PM: suspend entry (s2idle)
May 03 18:21:50 Dennis-Ritchie kernel: printk: Suspending console(s) (use no_console_suspend to debug)
May 03 18:21:50 Dennis-Ritchie kernel: NVRM: GPU 0000:01:00.0: PreserveVideoMemoryAllocations module parameter is set. System Power Management attempted without driver procfs suspend interface. Please refer to the 'Configuring Power Management Support' section in the driver README.
May 03 18:21:50 Dennis-Ritchie kernel: PM: pci_pm_suspend(): nv_pmops_suspend+0x0/0x30 [nvidia] returns -5
May 03 18:21:50 Dennis-Ritchie kernel: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1b0 returns -5
May 03 18:21:50 Dennis-Ritchie kernel: nvidia 0000:01:00.0: PM: failed to suspend async: error -5
May 03 18:21:50 Dennis-Ritchie kernel: PM: Some devices failed to suspend, or early wake event detected
May 03 18:21:50 Dennis-Ritchie kernel: PM: suspend exit
May 03 18:21:50 Dennis-Ritchie systemd-sleep[30440]: Failed to suspend system. System resumed again: Input/output error
May 03 18:21:50 Dennis-Ritchie systemd[1]: systemd-suspend.service: Main process exited, code=exited, status=1/FAILURE
May 03 18:21:50 Dennis-Ritchie systemd[1]: systemd-suspend.service: Failed with result 'exit-code'.
May 03 18:21:50 Dennis-Ritchie systemd[1]: suspend.target: Job suspend.target/start failed with result 'dependency'.

@wezel
Copy link

wezel commented May 5, 2023

The method works. In case you need fresh files install the services, you can get your driver version from NVIDIA. Use nvidia-smi to get the exact version and then run the .run file with --extract-only flag: sudo bash NVIDIA-Linux-x86_64-515.65.01.run --extract-only.

Then you run the given commands setting the TMPL_PATH to the path where you've extracted the files. Keep in mind that the files for this driver (515.65.01) have a slightly different locations as stated in the original post. So the updated commands should be like this:

TMPL_PATH=/home/user/Downloads/NVIDIA-Linux-x86_64-515.65.01/systemd

sudo install --mode 644 "${TMPL_PATH}/system/nvidia-suspend.service" /etc/systemd/system
sudo install --mode 644 "${TMPL_PATH}/system/nvidia-hibernate.service" /etc/systemd/system
sudo install --mode 644 "${TMPL_PATH}/system/nvidia-resume.service" /etc/systemd/system
sudo install "${TMPL_PATH}/system-sleep/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

I have the 530.30.02 drivers and this worked for me thanks! I almost gave up on it.

@Sahas-Ananth
Copy link

The method works. In case you need fresh files install the services, you can get your driver version from NVIDIA. Use nvidia-smi to get the exact version and then run the .run file with --extract-only flag: sudo bash NVIDIA-Linux-x86_64-515.65.01.run --extract-only.
Then you run the given commands setting the TMPL_PATH to the path where you've extracted the files. Keep in mind that the files for this driver (515.65.01) have a slightly different locations as stated in the original post. So the updated commands should be like this:

TMPL_PATH=/home/user/Downloads/NVIDIA-Linux-x86_64-515.65.01/systemd

sudo install --mode 644 "${TMPL_PATH}/system/nvidia-suspend.service" /etc/systemd/system
sudo install --mode 644 "${TMPL_PATH}/system/nvidia-hibernate.service" /etc/systemd/system
sudo install --mode 644 "${TMPL_PATH}/system/nvidia-resume.service" /etc/systemd/system
sudo install "${TMPL_PATH}/system-sleep/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

I have the 530.30.02 drivers and this worked for me thanks! I almost gave up on it.

Did you change the above command to 530.30.02 (your driver version) or 515.65.01 (The one given in the script)?

@wezel
Copy link

wezel commented May 9, 2023

Sort of. I downloaded the closest driver, to mine, I could "easily" find from the nvidia driver website and used the name of that version in the script. Which means that I changed all instances of 515.65.01 in the above command to 530.41.03. I hope this helps.
(do note: It would probably be better to match the exact version)

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