cudaGetLastError not compiling

Hello again. I’m afraid I’ve run into a strange little issue. I cannot seem to compile code containing cudaGetLastError as it says
NVFORTRAN-S-0155-Illegal call from host code to device subprogram __pgi_get_last_error

I’m using the cudafor package at the top and I’m compiling with
nvfortran -Mcuda -o exampleFile exampleFile.f90
and I’m using nvfortran 20.11-0 LLVM 64-bit target on x86-64 Linux -tp skylake

The code more or less looks like this

program exampleProgram
use cudafor
use exampleModule

integer :: errorID
call exampleKernal<<<>>>
errorID = cudaGetLastError()
write(,) cudaGetErrorString(cudaGetLastError())
end program exampleProgram

was cudaGetLastError depreciated since 2017 and can no longer be used from host code?

do you have

use cudadevice

anywhere in your code?

It’s in the module file because I was under the impression it was needed to use clock64. Is that not correct?

I don’t think it is required. And it is the source of this problem. Just try removing it.

Looks like it’s compiling, so I believe that did it.