I'm trying to run some examples from CUDA samples set, like volumeRender. Usually it works well on desktop, however now I'm launching them on the laptop with 2 GPU devices (integrated AMD and discrete NVIDIA). CLI CUDA examples work well, however when I'm trying to launch any example with Glut rendering it crashes with
CUDA error at volumeRender.cpp:435 code=999(cudaErrorUnknown) "cudaGraphicsGLRegisterBuffer( &cuda_pbo_resource, pbo, cudaGraphicsMapFlagsWriteDiscard)"
AFAIK it happens because of render context created on AMD instead of NVIDIA. I've tried to use various global environments to force nvidia, to setup appropriate flags directly in code like How to choose specific GPU when create OpenGL context or even to close the laptop's lid conecting a screen via HDMI to force discrete GPU to be active, but GLUT still selects AMD for renering. How to fix it?
Ubuntu 22.0, CUDA 12.6, HP Victus