Crash during NVSDK_NGX_CUDA_Init

Hello dear NGX Team!

I have two application of which one works fine, the other crashes during
NVSDK_NGX_CUDA_Init();

Both applications call this function nearly as first thing in main(),
with all parameters exactly the same.

I get correct errors for both if no RTX card is installed or the given
directory is inaccessible.

Both applications are compiled with cuda 9.1 (both load nvcuda.dll and cudart64_91.dll) on startup.

When I set HKLM\SOFTWARE\NVIDIA Corporation\Global\NGXCore\LogLevel
I get the following ouputs:

The good one:
‘TestNvNGX.exe’ (Win32): Loaded ‘C:\Program Files\NVIDIA Corporation\NVIDIA NGX\nvngx.dll’. Loading disabled by Include/Exclude setting.
‘TestNvNGX.exe’ (Win32): Loaded ‘C:\Program Files\NVIDIA Corporation\NVIDIA NGX\cudnn_infer64_7.dll’. Module was built without symbols.
[2020-01-27 14:27:11] [NGXLoadLibrary:231] Loaded NGXCore from path (C:\Program Files\NVIDIA Corporation\NVIDIA NGX/cudnn_infer64_7.dll)
[2020-01-27 14:27:11] [NGXLoadLibrary:231] Loaded NGXCore from path (nvcuda.dll)
Exception thrown at 0x00007FF9F5659159 in TestNvNGX.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0000008C3178EBD8.
Exception thrown at 0x00007FF9F5659159 in TestNvNGX.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
[2020-01-27 14:27:11] [NGXNVAPITelemetryInit:370] Failed to initialize telemetry : -2147467259
[2020-01-27 14:27:11] [NGXCheckHardwareSupportUsingINF:132] Found matching adapter with NVAPI physical GPU handle: 0x500 and LUID: { 0x0, 0xef77 }
[2020-01-27 14:27:11] [NGXCheckHardwareSupportUsingINF:153] Checking for key: NVSupportNGX, in the INF for GPU with physical handle: 0x500 and LUID: { 0x0, 0xef77 }

The crashing one:
‘TestNvNGX+.exe’ (Win32): Loaded ‘C:\Program Files\NVIDIA Corporation\NVIDIA NGX\nvngx.dll’. Loading disabled by Include/Exclude setting.
‘TestNvNGX+.exe’ (Win32): Loaded ‘C:\Program Files\NVIDIA Corporation\NVIDIA NGX\cudnn_infer64_7.dll’. Module was built without symbols.
[2020-01-27 14:29:10] [NGXLoadLibrary:231] Loaded NGXCore from path (C:\Program Files\NVIDIA Corporation\NVIDIA NGX/cudnn_infer64_7.dll)
[2020-01-27 14:29:10] [NGXLoadLibrary:231] Loaded NGXCore from path (nvcuda.dll)
Exception thrown at 0x00007FF9A6AEE8C9 (nvngx.dll) in TestNvNGX+.exe: 0xC0000005: Access violation reading location 0x00007FF900000047.

The program ‘[0x3338] TestNvNGX+’ has exited with code 0 (0x0).

I have the latest driver (441.66-quadro-desktop-notebook-win10-64bit-international-whql) installed as well as the latest nvngx sdk (1.1).

The main difference ist that the crashing one, links to some other libraries making use of cuda and opengl functions, and is multithreaded. Put as said the call to init is done right in main at the very beginning.

Any more hints or ideas?

Thanks, P

I think I have found the solution.
The working application did call a cudaMalloc() before calling NVSDK_NGX_CUDA_Init().

Putting a cudaMalloc(&p, 1) or a cudaSetDevice(0) before NVSDK_NGX_CUDA_Init() fixed the crash.

Regards, P