Sometimes unable to suspend OS: Failed to map NvKmsKapiMemory

There seems to be a timing problem between Gnome and the NVIDIA driver during suspend, this post explains the problem and has a solution based on systemd services that pause gnome-shell before suspend and unpauses it after resume.

I have implemented the solution and it looks promising, several suspend/resume operations still working after several reboots. I’ve been searching for a solution for this issue for a long time and I’m cautiously optimistic.