the device being used is no longer there (MATLAB + GPU)
2 次查看(过去 30 天)
显示 更早的评论
hi Folks: This bothers me: I have 2 GPU cards on my machine. I designate the 2nd one to use in my MATLBA code, but I got following error:
The device being used is no longer current.
Error in deriv_optcontMxy_cuda (line 18)
gpuderivMxy.GridSize = [min(1024,tmp.MaxGridSize(1)) 1]; % min(1024, maxblocks)
Error in optcontMxyHBG (line 72)
drfn = deriv_optcontMxy_cuda(rfn,gamgdtn,xx,auxa,auxb,a,b,rfmask);
I am not sure why; Here is my code:
persistent gpuderivMxy
persistent drfrt drfit;
Nt = size(rf,1);
Ns = size(xx,1);
Ndim = size(xx,2);
if isempty(gpuderivMxy)
disp 'Initializing GPU drf calculation...';
gpuderivMxy = parallel.gpu.CUDAKernel('deriv_optcontMxy_cuda.ptx','deriv_optcontMxy_cuda.cu','deriv_optcontMxy_cuda');
tmp = gpuDevice(2);
gpuderivMxy.GridSize = [min(1024,tmp.MaxGridSize(1)) 1]; % min(1024, maxblocks)
gpuderivMxy.ThreadBlockSize = [min(128, tmp.MaxThreadsPerBlock) 1 1]; % min(128, maxthreadsperblock)
drfrt = gpuArray(zeros(Ns, Nt));
drfit = gpuArray(zeros(Ns, Nt));
end;
If I do not use tmp = gpuDevice(2), only tmp = gpuDevice(); it has no mistake like above;
Any one has any idea why this is happening? I appreciate it.
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing in MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!