I have a Microsoft Surface Book 2 which allows the user to undock the dedicated GTX 1050 graphics card and keyboard from the base computer, running on windows 10 x64 and cuda 9.2.
Now I have created a simple application and a dynamic dll:
-The dynamic dll contains the following code on an exported function:
int count; cudaError_t error = cudaGetDeviceCount(&count); printf("%i %i\n",count,error);fflush(stdout);
-The main application perform a loadlibrary on the dll, then getprocaddress on this method, then calls it, then freelibrary. This is encapsulated in a loop running it every minute
Everything works well when the dedicated graphics card stays docked, every minute, I get the same output: 1 dedicaded graphics card, error is 0.
Now, after a few loop iterations, if I undock the grahics card then redock it after a bit, I get error code 3 (initialization error), and the only way to make it work again is to restart the app.
Note that if instead of using a dll, I call the code directly in the main application, this scenario provides the correct output after the redock.
Why am I using a dynamic dll then: I want to be able to undock the graphics card during runtime after freeing the dll. For now it works for the first undock but I am unable to reinitialize gpu resources after the redock without having to restart my application.
Thank you very much for your help!