Recently I've been moving my gaming rig from Windows 10 to Linux. After seeing how well everything works in the Steam Deck, I would prefer to be out of Windows as much as possible.

After preparing everything (I use Ubuntu 20.04 LTS as my Linux OS) and installing the latest Nvidia Graphics, I set up Steam and started playing my actual games (I'm pretty "busy" with Diablo IV) and everything went really fine.

But, one little issue appeared, after putting the computer in standby (suspend to ram) and resuming, the Steam UI did not work and hanged. I had to kill it and restart it.

The problem had to do with activating Steam UI Hardware Acceleration, that I had to enable because if not, the UI was really laggy.

If I disabled those options, Steam UI was working properly after resuming from STR.

After asome digging, I found out a post in the Steam Community Forums that fixed the problem and I wanted to resume here the steps that worked for me.

1- Enable NVidia Suspend Service

sudo systemctl enable nvidia-suspend.service

2- Prepare a folder where the driver will store graphics memory. We want this to be into a ramdisk to optimize the suspend time. In my case, /tmp is not a ramdisk and it is stored in the root FS and because of that, I created a folder and configured fstab to mount it on restart:

sudo mkdir /tmp/nvidia-tmpfs
sudo vi /etc/fstab

Append to the file this line (and save it):

tmpfs /tmp/nvidia-tmpfs tmpfs defaults 0 0

3- Create a module config for NVidia driver to use the temporary folder when computer is going STR:

sudo vi /etc/modprobe.d/nvidia-power-management.conf

And add this line to the file:

options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=/tmp/nvidia-tmpfs

This line will tell the driver to enable the Video Memory storage to file when going STR

4- We need to update initramfs to include the module configuration:

sudo update-initramfs -u

5- Reboot to enable these changes.

After the computer being rebooted, you can check if driver is properly configured to handle STR correctly with theses command and their expected response:

$ grep -i pres /proc/driver/nvidia/params
PreserveVideoMemoryAllocations: 1

$ grep -i temp /proc/driver/nvidia/params
TemporaryFilePath: "/tmp/nvidia-tmpfs"

If you see "1" for PreserveVideoMemoryAllocations, you are fine (a 0 will be a bad thing) and in the TemporaryFilePath you should see the path we setup prevously.

One last check would be ensuring the folder we created previously for storing video ram is indeed a tmpfs, you can check this with this command:

$ df /tmp/nvidia-tmpfs/
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs            8158628     0   8158628   0% /tmp/nvidia-tmpfs

If in the Filesystem column you get "tmpfs" everything is fine