How to directly run ./test, instead of __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia ./test

how to directly run ./test, instead of __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia ./test
is there something can be added to the code, or CMake, or makefile?

./test ;
sudo prime-select nvidia , then ./test
these 2 methods above both NOT work…

working on Ubuntu, Thanks!

add ‘__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia’ to enviroment var is the only way?

One way to put it into a script. i.e.

Or just sudo prime-select nvidia. reboot.
But then everything is generally rendered on the nvidia gpu.

thanks! the reason is Ubuntu still cannot swith to Nvidia Gpu from intel gpu dynamically when exe start? even with CUDA installed and used in the exe?