VSB
VSB

Reputation: 242

cudaGetDeviceCount returns error: 1 invalid argument

Running this code:

int device = 0;
cudaGetDevice(&device);
cudaDeviceProp props;
cudaGetDeviceProperties(&props, device);
const int kb = 1024;
const int mb = kb * kb;

cout << "Module Start:" << endl;
cout << props.name << ": " << props.major << "." << props.minor << endl;
cout << "  Global memory:   " << props.totalGlobalMem / mb << "mb" << endl;
cout << "  Shared memory:   " << props.sharedMemPerBlock / kb << "kb" << endl;
cout << "  Constant memory: " << props.totalConstMem / kb << "kb" << endl;
cout << "  Block registers: " << props.regsPerBlock << endl;
cout << "  Warp size:         " << props.warpSize << endl;
cout << "  Threads per block: " << props.maxThreadsPerBlock << endl;
cout << "  Max block dimensions: [ " << props.maxThreadsDim[0] << ", " << props.maxThreadsDim[1] << ", " << props.maxThreadsDim[2] << " ]" << endl;
cout << "  Max grid dimensions:  [ " << props.maxGridSize[0] << ", " << props.maxGridSize[1] << ", " << props.maxGridSize[2] << " ]" << endl;
cout << endl;

Results in the following garbage output and crash on RTX 2060, x64 Windows 10 on friend's computer:

error output

EDIT: I added some error checks:

int devicesCount;
cudaError_t error_id = cudaGetDeviceCount(&devicesCount);

if (error_id != cudaSuccess) {
    printf("cudaGetDeviceCount returned %d\n%s\n", (int)error_id, cudaGetErrorString(error_id));
    return 1;
} else {
    printf("Found %d GPUs\n", devicesCount);
}

and this is the error: cudaGetDeviceCount returns error: "return 1, invalid argument"

It also appears he is using Windows insider edition and Driver Version 465.21, which is newer than the current stable release.

Works on the 1070, x64 Windows 10:

enter image description here

I tried using this post to get and set the active device, but that gave the same garbage output.

I am compiling to a .DLL and calling the functions through Python. It is possible that my Visual Studio project settings got messed up somehow, because it was working on friend's 2060 before.

"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\nvcc.exe" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" -gencode=arch=compute_60,code=\"sm_60,compute_60\" -gencode=arch=compute_61,code=\"sm_61,compute_61\" -gencode=arch=compute_70,code=\"sm_70,compute_70\" -gencode=arch=compute_75,code=\"sm_75,compute_75\" -gencode=arch=compute_80,code=\"sm_80,compute_80\" -gencode=arch=compute_86,code=\"sm_86,compute_86\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64" -x cu   -I./ -I../../common/inc -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include"     --keep-dir x64\Release  -maxrregcount=0  --machine 64 --compile -cudart shared --threads 0   -DWIN32 -D_MBCS -D_WINDLL -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Fdx64/Release/vc142.pdb /FS   /MD " -o x64/Release/gpu_compute.cu.obj "D:\Tests\MyDLL\gpu_compute.cu"

Upvotes: 0

Views: 736

Answers (1)

VSB
VSB

Reputation: 242

The error was caused by not yet released Driver Version 465.21 shipped with the Windows Insider edition. Rolling back to current 461.40 solved this.

Upvotes: 1

Related Questions