This little piece of code:
integer(KIND=4) :: nb integer :: err err=cudaGetDeviceCount(nb) print*,nb,'cuda capable GPUs on this node'
Gives me this result with version 11.6 of the compiler:
32767 cuda capable GPUs on this node
and this result with version 11.1:
4 cuda capable GPUs on this node
Unfortunately for me, it is version 11.1 which gives the correct answer.
Looks like an unsigned integer issue. It looks like the problem is similar with the cudaSetDevice() function.