Try removing “-gpu=cuda12.1” and just setting NVHPC_CUDA_HOME. The -gpu=cudaXX.Y flag only switches between the CUDA versions that are installed as part of the NVHPC SDK.
If you add the verbose flag (-v), you can see the paths being used by the compiler and confirm that it’s using your local CUDA install.
-Mat