思路

顯卡有專門的內顯(VRAM))儲存資料。在休眠以前,如果 VRAM 沒有正確保存、還原,喚醒後螢幕就會顯示異常。

說 Linux 系統設備在休眠,通常是指其進入 ACPI 定義的 S3 狀態。在此狀態下,CPU 停止、週邊設備斷電,但主機板會持續對 System RAM 供電。也就是說,強制系統在休眠以前把所有的 VRAM 內容寫入 RAM 或 Swap,並在喚醒時全數還原即可。可透過 NVIDIA 的設定檔調整。

操作

建立/編輯 /etc/modprobe.d/nvidia-power-management.conf,請系統保留所有 VRAM

options nvidia NVreg_PreserveVideoMemoryAllocations=1

啟用 NVIDIA 提供的 Systemd 電源管理的掛鉤(hooks)服務。

sudo systemctl enable nvidia-suspend.service
sudo systemctl enable nvidia-hibernate.service
sudo systemctl enable nvidia-resume.service

更新 initramfs

sudo update-initramfs -u
sudo reboot

參考資料

  1. https://forums.developer.nvidia.com/t/glitches-and-messed-up-colours-after-wake-up-on-gtx-1650-ti-ryzen-4800h-ubuntu-20-10/176380