-
Star
(112)
You must be signed in to star a gist -
Fork
(2)
You must be signed in to fork a gist
-
-
Save bmcbm/375f14eaa17f88756b4bdbbebbcfd029 to your computer and use it in GitHub Desktop.
| # 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 | |
Fedora 43 Workstation
ThinkPad P16s Gen 2
6.18.6-200.fc43.x86_64
GNOME 49.3
GPU 1: NVIDIA RTX A500 Laptop GPU
GPU 2: Intel Iris Xe Graphics @ 1.50GHz [Integrated]
/etc/modeprobe.d/nvidia.conf:
# Disable Nvidia modesetting for hyprid graphics
options nvidia-drm modeset=0
# Enable dynamic power management
options nvidia NVreg_DynamicPowerManagement=0x02
# Disable GSP firmware (can cause issues on some laptops)
options nvidia NVreg_EnableGpuFirmware=0
# Preserve video memory allocations across suspend/resume
options nvidia NVreg_PreserveVideoMemoryAllocations=1
# Disable S0ix power management
options nvidia NVreg_EnableS0ixPowerManagement=0I tried the systemctl enable nvidia commands but this never fixed my problem.
What worked for me was disabling USB and THunderbolt wake:
# Disable XHCI (USB)
echo XHCI | sudo tee /proc/acpi/wakeup
# Disable TXHC (Thunderbolt)
echo TXHC | sudo tee /proc/acpi/wakeup
# Verify both are disabled
cat /proc/acpi/wakeup | grep -E "XHCI|TXHC"Both should be *disabled - I have to use my laptop keyboard/trackpad to resume but I am fine with that so keep it in mind if you are not using a laptop.
I think that something was sending wake signals hence why I disabled those.
To make it permanent create a service for it:
/etc/systemd/system/disable-usb-wakeup.service:
[Unit]
Description=Disable USB wakeup to prevent spurious wake events
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'echo XHCI > /proc/acpi/wakeup; echo TXHC > /proc/acpi/wakeup'
[Install]
WantedBy=multi-user.targetsudo systemctl enable disable-usb-wakeup.service
sudo systemctl start disable-usb-wakeup.serviceUbuntu 24.04
nvidia-driver-590-open 590.48.01
NVIDIA GeForce RTX 3080
$ echo $XDG_SESSION_TYPE
x11
(not running Wayland)
The first line below (from journalctl -b -1) was key for me:
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.
kernel: nvidia 0000:01:00.0: PM: pci_pm_suspend(): nv_pmops_suspend+0x0/0x50 [nvidia] returns -5
kernel: nvidia 0000:01:00.0: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1b0 returns -5
kernel: nvidia 0000:01:00.0: PM: failed to suspend async: error -5
kernel: PM: Some devices failed to suspend, or early wake event detected
Following that clue (and working my way through all the ideas described in this thread), I edited /etc/modprobe.d/nvidia-graphics-drivers-kms.conf to
# This file was generated by nvidia-driver-590
# Set value to 0 to disable modesetting
options nvidia_drm modeset=1
# Preserve video memory on suspend/resume
options nvidia NVreg_PreserveVideoMemoryAllocations=0 # <-- this is all I changed
options nvidia NVreg_TemporaryFilePath=/var
and ran sudo update-initramfs -u and rebooted.
... I also enabled a bunch of services, but I'm not sure it was necessary (and definitely wasn't sufficient):
$ systemctl list-unit-files | grep nvidia
nvidia-hibernate.service enabled enabled
nvidia-persistenced.service static -
nvidia-resume.service enabled enabled
nvidia-suspend-then-hibernate.service enabled enabled
nvidia-suspend.service enabled enabled
On Debian 13 (Trixie) I have fiddled with nvidia CUDA toolkit installed from https://developer.nvidia.com/cuda-downloads, then uninstalled it and opted for the Debian native packages (nvidia-cuda-toolkit).
As reported by others here, after the reboot suspend is broken, and there are broken symlinks:
find /etc/systemd -type l -exec file {} \; | grep broken | grep nvidia
/etc/systemd/system/systemd-suspend.service.wants/nvidia-suspend.service: broken symbolic link to /usr/lib/systemd/system/nvidia-suspend.service
/etc/systemd/system/systemd-suspend.service.wants/nvidia-resume.service: broken symbolic link to /usr/lib/systemd/system/nvidia-resume.service
/etc/systemd/system/systemd-hibernate.service.wants/nvidia-resume.service: broken symbolic link to /usr/lib/systemd/system/nvidia-resume.service
/etc/systemd/system/systemd-hibernate.service.wants/nvidia-hibernate.service: broken symbolic link to /usr/lib/systemd/system/nvidia-hibernate.service
ls -l /etc/systemd/system/systemd-suspend.service.wants/nvidia-resume.service
lrwxrwxrwx 1 root root 45 12 set 07.16 /etc/systemd/system/systemd-suspend.service.wants/nvidia-resume.service -> /usr/lib/systemd/system/nvidia-resume.service
In my case though, I fixed not by removing the symlinks, but by restoring the targets:
sudo apt remove nvidia-suspend-common
sudo apt install nvidia-suspend-common
ls -l /usr/lib/systemd/system/nvidia*
-rw-r--r-- 1 root root 270 8 apr 2025 /usr/lib/systemd/system/nvidia-hibernate.service
-rw-r--r-- 1 root root 1501 17 dic 02.37 /usr/lib/systemd/system/nvidia-persistenced.service
-rw-r--r-- 1 root root 321 8 apr 2025 /usr/lib/systemd/system/nvidia-resume.service
-rw-r--r-- 1 root root 258 8 apr 2025 /usr/lib/systemd/system/nvidia-suspend.serviceNow the symlinks are not broken anymore and suspend/resume works again! Hope this helps
Initial tests, this works for me on Mint 22.2, Driver Version: 580.105.08 to get suspend working:
systemctl enable nvidia-suspend.service
systemctl enable nvidia-hibernate.service
systemctl enable nvidia-resume.service
my /etc/modprobe.d/nvidia-graphics-drivers-kms.conf:
options nvidia-drm modeset=1
options nvidia NVreg_PreserveVideoMemoryAllocations=0
options nvidia NVreg_TemporaryFilePath=/var/tmp