Skip to content

Instantly share code, notes, and snippets.

@bmcbm
Last active December 16, 2024 00:24
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
@ethanh20009
Copy link

apparently fix is going to be available in upcoming 565 linux driver release. NVIDIA/open-gpu-kernel-modules#662 (comment)

@Kleisli
Copy link

Kleisli commented Oct 4, 2024

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

I can confirm this also fixes the resume from suspend problem for me:
Ubuntu 24.04, Nvidia Quadro M2000M, with the latest nvidia driver 560 and it works also on wayland

thank you @chanh2018!

@avoiceofreason
Copy link

For info. I'm on nvidia driver version 555.58.02

After a lot of trial, error and luck, I commented out the fbdev=1 line in the /etc/modprobe.d/nvidia-graphics-drivers-kms.conf file and resume started to work again. Oh and don't forget to sudo update-initramfs -u and reboot first of course......

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

@Kleisli
Copy link

Kleisli commented Nov 1, 2024

I can confirm this also fixes the resume from suspend problem for me: Ubuntu 24.04, Nvidia Quadro M2000M, with the latest nvidia driver 560 and it works also on wayland

thank you @chanh2018!

it worked on Ubuntu 24.04 but broke again on 24.10 :-(

what fixed it for me again - for now - was

  • Switching to the Nouveau driver in "Software & Updates" > Additional drivers
  • and then purge all nvidia packages... sudo apt --purge remove "*nvidia*"

@blakkd
Copy link

blakkd commented Nov 15, 2024

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

Thanks!

@heronsanches
Copy link

heronsanches commented Nov 16, 2024

Configuration: NVIDIA GeForce RTX™ 3050 Laptop GPU | Fedora 41 | Kernel GNU/Linux 6.11.7-300

As I've tried many things, I had to do a cleanup first.
sudo dnf remove \*nvidia\* --exclude nvidia-gpu-firmware

Check if the nouveau driver is disabled.. Follow up the section 2.6.

Install the nvidia drivers from RPM repository.
sudo dnf install akmod-nvidia

Remove nvidia sleep service.
sudo rm /lib/systemd/system-sleep/nvidia

For what I've been experienced, I think that what causes the problem is the "integration of all" and the nvidia sleep service.

@ethanh20009
Copy link

Okay, clearing things up the issue has been resolved:

  1. Either use LTS kernel (6.6) or 6.12rc.
  2. Make sure to enable nvidia-suspend, nvidia-resume and nvidia-hibernate systemd services.
  3. Make sure you have fbdev and NVreg_PreserveVideoMemoryAllocations=1 (and /var/tmp path etc)
  4. Use nvidia open dkms 565 drivers.

@apienk
Copy link

apienk commented Nov 17, 2024

As a side note, mind that a GNOME extension or another program may interfere with suspend by failing to release the /dev/nvidia handle (you will see wait requests sent by the driver to the shell in the logs). In my case it was the Vitals GNOME extension. Once I removed it, Ubuntu 24.04.1 suspends and resumes without any issues.

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