Hi guys,
I have a question which puzzles me for a long time:
I am using LabVIEW to call into my DLLs containing some CUDA functions, but after the function completes, I found the LabVIEW is bundled to the CPU 0, while the CPU 1 got unchecked… Please see the attachment. Both the CPU 0 & 1 will not get unchecked if the DLL does not contain the CUDA code.
This is really an unwanted behaviour for me since I want the GPU and CPU to work together, setting LabVIEW bundle to CPU 0 just make the CPU 1 idle and this is unacceptable for my application. Although I can use the Windows API ‘SetProcessAffinityMask’ to put my LabVIEW back onto two cores, but I consider this only a workaround… Does anyone have any idea about why the CPU affinity can be automatically modified by CUDA and how to prevent this? Thanks.
The profiler does this for accurate timing.
Does this mean that I will NOT see the phenomenon once I close the profiler? Thanks.
And I will try it again.
Hi tmurray,
I tried running the DLL without opening the ‘CUDA Visual Profiler’, but that problem still persists. Am I missing any operation here? Does the profiler you pointed out is the ‘CUDA Visual Profiler’?
Could you show me a way to ‘turn off’ the profiler?
Thanks again.
Some of the cutil timers set process affinity as well. Are you using any of those?
–Cliff
Hi Cliff,
In my simplest code, I didn’t use any cutil timer, I have attached my test code below:
[codebox]void test()
{
float *data;
cudaMalloc((void**)&data, sizeof(float)*10);
cudaFree(data);
}[/codebox]
Once I finish running the code above, the affinity of LabVIEW is modified…
I strongly suspect the affinity is set when the CUDA runtime engine is loaded, see the code snippet below:
[codebox]void test()
{
float *data;
PrintOutAffinity("Begin the program");
cudaMalloc((void**)&data, sizeof(float)*10);
PrintOutAffinity("After the malloc");
SetAffinity(3);
PrintOutAffinity("After reset the affinity");
cudaFree(data);
PrintOutAffinity("After the free");
cudaThreadExit();
}[/codebox]
The function ‘PrintOutAffinity’ prints out the current affinity of the process, and the function ‘SetAffinity’ just set the process affinity to 3. The execution result is shown below:
[codebox]Begin the program 3
After the malloc 1
After reset the affinity 3
After the free 3[/codebox]
It’s clearly seen above that the affinity is only set once at the first CUDA function call, if I set the affinity back to 3, and it will never be modified again. So I think the affinity is only modified once at the same time with the CUDA runtime engine load.
Sound reasonable?
Do you have the CUDA_PROFILE environment variable set to 1?
Hi tmurray,
You are the man!!! You just help solve a problem which bothers me for a month!!! Great thanks.