# 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 | |
Thanks for the suggestion, I tried deleting and it worked.
However, according to docs v515, the the nvidia systemd config files are still used, the documentation mentioned it as if the files are supposed to be there (Unless they forgot to update the docs). Looking at the shell script in this post, it seems to call nvidia driver suspend, so removing them would remove this behavior?
/usr/bin/nvidia-sleep.sh
#!/bin/bash
if [ ! -f /proc/driver/nvidia/suspend ]; then
exit 0
fi
RUN_DIR="/var/run/nvidia-sleep"
XORG_VT_FILE="${RUN_DIR}"/Xorg.vt_number
PATH="/bin:/usr/bin"
case "$1" in
suspend|hibernate)
mkdir -p "${RUN_DIR}"
fgconsole > "${XORG_VT_FILE}"
chvt 63
if [[ $? -ne 0 ]]; then
exit $?
fi
echo "$1" > /proc/driver/nvidia/suspend
exit $?
;;
resume)
echo "$1" > /proc/driver/nvidia/suspend
#
# Check if Xorg was determined to be running at the time
# of suspend, and whether its VT was recorded. If so,
# attempt to switch back to this VT.
#
if [[ -f "${XORG_VT_FILE}" ]]; then
XORG_PID=$(cat "${XORG_VT_FILE}")
rm "${XORG_VT_FILE}"
chvt "${XORG_PID}"
fi
exit 0
;;
*)
exit 1
esac
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
This works perfectly
I'm on Ubuntu 22.04, and after installing CUDA I was unable to suspend. The following steps worked for me:
- Inside
/etc/systemd
, delete all of the files that includenvidia
andsuspend
orhibernate
. There are three services inside/etc/systemd/system
, which I deleted. There are also some other dead nvidia links insidesystemd-hibernate.service.requires
,systemd-suspend.service.requires
, which I deleted.I wish I knew the exact names of the files that I deleted, but since they're now gone, I can't remember their exact paths. But in a nutshell, go into
/etc/systemd
, and dofind . -iname nv*
, and then delete all the of thesuspend
,resume
, andhibernate
scripts.DO NOT DELETE
nvidia-powerd.service
andnvidia-persistenced.service
.Once you're done with that, do
systemctl daemon-reload
.
This works! Thanks a lot!
I'm on Ubuntu 22.04, and after installing CUDA I was unable to suspend. The following steps worked for me:
- Inside
/etc/systemd
, delete all of the files that includenvidia
andsuspend
orhibernate
. There are three services inside/etc/systemd/system
, which I deleted. There are also some other dead nvidia links insidesystemd-hibernate.service.requires
,systemd-suspend.service.requires
, which I deleted.I wish I knew the exact names of the files that I deleted, but since they're now gone, I can't remember their exact paths. But in a nutshell, go into
/etc/systemd
, and dofind . -iname nv*
, and then delete all the of thesuspend
,resume
, andhibernate
scripts.DO NOT DELETE
nvidia-powerd.service
andnvidia-persistenced.service
.Once you're done with that, do
systemctl daemon-reload
.
This doesn't worked form me.
I removed all nvidia files you said. Indeed, if i do systemctl list-unit-files | grep nvidia
it returns
nvidia-persistenced.service enabled enabled
nvidia-powerd.service enabled enabled
and with find /etc/systemd -iname nv*
/etc/systemd/system/multi-user.target.wants/nvidia-persistenced.service
/etc/systemd/system/multi-user.target.wants/nvidia-powerd.service
but I'm still not able to resume the laptop.
My nvidia-smi
is
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| 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 ... On | 00000000:01:00.0 Off | N/A |
| N/A 49C P8 2W / N/A | 634MiB / 4096MiB | 8% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 2112 G /usr/lib/xorg/Xorg 216MiB |
| 0 N/A N/A 2468 G /usr/bin/gnome-shell 50MiB |
| 0 N/A N/A 3944 G ...589584913286235972,131072 366MiB |
+-----------------------------------------------------------------------------+
@bmharper Your solution works perfectly for me (driver 515)!
Thanks @bmharper !!! Worked for me too, in the Nvidia On-Demand mode. I haven't tried other modes yet, but I'm fine with this one.
My story is: Linux Mint 20.3 Cinnamon, kernel 5.4.0-126. Recently installed CUDA toolkit, which updated my nvidia driver from 470 (if I'm not mistaken) to 515, which in turn had broken my auto-suspend on lid close. The Quit->Suspend button haven't worked either. Only way I could suspend is by running pm-suspend
from terminal.
@bmharper That works for alienware laptop with nvidia driver 515
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.
BTW: I also update the driver to version 520, and upgrade ubuntu to 22.04.1 LTS. Works fine.
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.
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.
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.
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
@marani I also experienced issues with hibernate after installing Nvidia CUDA drivers.
See the comment by @bmharper above.
I found that there were some broken links to the missing systemd service units for uspend and hibernate. Check if you have such broken links and remove them if you do.