Skip to content

Instantly share code, notes, and snippets.

@bmcbm
Last active October 9, 2024 03:12
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
@bilallamal07
Copy link

After so many trials I found a solution for myself. I'm not sure it'll work for yours but at least it's working for my system now. Here' what I did:

  • Switch back to nouveau open source driver (if you're using proprietary driver)
  • Manually install Nvidia 550 driver ( sudo apt install nvidia-driver-550)
  • Reboot system and check if Nvidia 550 is installed
  • Create nvidia.conf file and add these lines into it (not sure about yours, but my system doesn't have this file)
  • nvidia.conf file will be in /etc/modprobe.d
    sudo nano /etc/modprobe.d/nvidia.conf
  • Add these lines into it:
    options nvidia-drm fbdev=1
    options nvidia NVreg_PreserveVideoMemoryAllocations=1
    options nvidia NVreg_TemporaryFilePath=/var/tmp
  • Reboot your system.
  • That's work for me

My system info: Dell Optiplex 9020 Intel i7-4790 4GHz Memory 16GBytes Video card: Nvidia GeForce GTX 745 Kernel 6.8.0-41-generic Linux Mint 22, Cinammon 6.2.9

(By the way, I tried this method on Nvidia driver 535 but it didn't work. Also, I got some ACPI errors before restart/shutdown, but not on start up, other than that, the system is running fine) I hope this info help someone who is looking for a solution of not wake-up from suspend as mind. Cheers !!!

l have tried this hack NVIDIA sleep script: /usr/bin/nvidia-sleep.sh

Adding exit 0 at the top of this script solved the problem.

This solution effectively bypasses the NVIDIA-specific sleep handling,
which was causing the suspend/resume issues. Here's how to implement this
fix properly many thanks :

Open the NVIDIA sleep script with sudo privileges:
sudo nano /usr/bin/nvidia-sleep.sh

Add exit 0 as the second line of the file,

#!/bin/bash
exit 0 <<---- This is the ;-) Hack

it worked for while, than the issue back again Can’t resume after suspend with 550 driver on OS: Linux Mint 21.3 x86_64
Kernel: 5.15.0-118-generic

Wed Sep 4 15:11:48 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.107.02 Driver Version: 550.107.02 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce GTX 960M Off | 00000000:02:00.0 Off | N/A |
| N/A 39C P8 N/A / 200W | 7MiB / 4096MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 1115 G /usr/lib/xorg/Xorg 2MiB |
+-----------------------------------------------------------------------------------------+

l have also tried

nvidia.conf file will be in /etc/modprobe.d # tried this not working for me
sudo nano /etc/modprobe.d/nvidia.conf
Add these lines into it:
options nvidia-drm fbdev=1
options nvidia NVreg_PreserveVideoMemoryAllocations=1
options nvidia NVreg_TemporaryFilePath=/var/tmp

No Joy ;-( still have the same issue any help or pointer that would be greatly appreciated

@chanh2018
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

@wuqi001s
Copy link

wuqi001s commented Sep 6, 2024

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.该方法有效。如果您需要新文件,请安装服务,您可以从 NVIDIA 获取您的驱动程序版本。使用 nvidia-smi 获取确切版本,然后使用 .run 文件和 --extract-only 标志运行: 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 设置为您提取文件的路径。请记住,此驱动程序 (515.65.01) 的文件位置与原始帖子中所述略有不同。因此,更新后的命令应如下所示:

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

535.183.01 works! thanks !535.183.01 有用!谢谢!

Sadly,it doesn't work for me.same is 535.183.01. Until now ,I have tried almost all methods ,no one work for me.It's so terrible.

@tabascoz
Copy link

same with me - Gentoo fully up to date as of today. - I'm not able to go past over 535.183.01 or kernel 6.9. Terrible.

@the-rich-piana
Copy link

Fix also stopped working for me. Frustrating. @chanh2018 what do these changes do?

@chanh2018
Copy link

Fix also stopped working for me. Frustrating. @chanh2018 what do these changes do?

To preserve video memory for NVIDIA. It works for me.

@tvld
Copy link

tvld commented Sep 27, 2024

After a completely new install of Ubuntu, which was needed as my NVME SSD WD 750 1TB completely died suddenly, I reinstalled 24.04 on a new Samsung 780 1TB. Most worked smoothly except the Suspend. Resume gave me a black screen with

DMAR: DRHD: handling fault status reg 2
DMAR: [INTR-REMAP]  REquest device [fo:1f.0] fault index 0x0 [fault reason 0x25] Blocked compatibility format interrupt request

I just tried the following from @chanh2018 and I just got my first successful resume. 😀

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

Note: the error messages still appear quickly on screen, but the system no longer hangs after that...

@giancarlo64
Copy link

I also have Mint 22 based on ubuntu 24.04 and had the same problem. This solved the problem for me:

https://forums.developer.nvidia.com/t/fixed-suspend-resume-issues-with-the-driver-version-470/187150/3

@typoworx-de
Copy link

Any news on this? Recently my new Working Notebook with dedicated nvidia gpu worked fine (with Ubuntu 23.04 and proprietary nvidia drivers). But after some update of Kernel and/or nvidia drivers my Notebook didn't wake-up from sleep mode. It's still available by SSH! But monitors keep off/no-signal whatever I do.

It totally sucks as I have to reboot (REISUB-Reboot) my Workstation nearly every morning and every morning I'm praying monitors won''t keep blank giving me the chance just to start working.

Any solution that works? I've tried nearly everything and now I'm even trying to totally disable sleep/hibernate/standby stuff.

Btw. I have linux-kernel 6.8.0-101041(-tuxedo) and (ubuntu/dpkg) nvidia drivers 560.

@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!

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