I can’t help with prevention but you can use the below to avoid rebooting as I was experiencing similar issues after resuming my computer from suspend.
You need to exit darktable before running the commands. This works for me on Ubuntu 20.04.
sudo rmmod nvidia_uvm
sudo modprobe nvidia_uvm
See Darktable disabled opencl - way to restart without rebooting ?