loop until nvidia_uvm is loaded


I’m using optix prime on ubuntu. On some target machines the nvidia_uvm module is not loaded properly at boot and this creates all sort of issues. I was hoping to write a loop at the beginning on my code that would try to create a context and if it fails, tell the user to run modprobe to load the nvidia_uvm module.

however, when I load the uvm module, the context creation still fails. I have to kill the process and start it again.

Is there a solution to this?