PCT GPU Computing: CUDA error was: setting the device when a process is active is not allowed
显示 更早的评论
Hi, everyone!
It seems to me that there is a problem in Parallel Computing Toolbox (PCT) with CUDA operation. The problem is that the setting of CUDA device in PCT fails, if CUDA device has been set up earlier within the same process by someone else, therefore, I cannot use PCT functionality, working with CUDA in my application which is also used by CUDA.
I will give you a simple example. Here it is:
% Starting MATLAB Environment...
% 1. Load a DLL file used by CUDA (or MEX file, it does not matter, only for example)
loadlibrary('MyComputingLib.dll', 'MyComputingLib.h', 'alias', 'cuda_lib')
% 2. perform calculations...
% 3. try to use PCT CUDA...
gpuDevice()
% ... and the error message appears:
An unexpected error occurred during CUDA execution. The CUDA error was: setting the device when a process is active is not allowed.
If the aforementioned actions are performed in the reversed order, the error does not occur (My software works correctly with CUDA device setting). Why cannot MATLAB set up CUDA device, when, starting with CUDA 4.0 version, it is possible to set up CUDA device a multiple number of times within one process?
I think this limitation is the rudiment of what has been left from the old CUDA versions (old derivers), when it was impossible to set up a device a multiple number of times after the process start.
Thank you in advance for your answer.
采纳的回答
更多回答(1 个)
I seem to be experiencing the same thing. Hope TMW can comment...
However, if what I'm seeing is the same as you, a simple workaround is to do something like this in startup.m
a=gpuArray(1); clear a
I find that as long as gpuArray is the first thing to use the GPU in the MATLAB session, things seem to work normally.
1 个评论
David Pate
2016-12-5
编辑:David Pate
2016-12-5
I also had this problem in Matlab 2016a, and I'm using a solution similar to yours. In my startup file I have:
try
gpu = gpuDevice;
clear gpu;
catch
disp('No GPU device found during startup');
end
类别
在 帮助中心 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!