the device being used is no longer there (MATLAB + GPU)

1 回表示 (過去 30 日間)
Nick Tsui
Nick Tsui 2012 年 7 月 26 日
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.

採用された回答

Nick Tsui
Nick Tsui 2012 年 7 月 26 日
編集済み: Nick Tsui 2012 年 7 月 26 日
I think if you put
tmp = gpuDevice(2)
before
gpuderivMxy = parallel.gpu.CUDAKernel('deriv_optcontMxy_cuda.ptx','deriv_optcontMxy_cuda.cu','deriv_optcontMxy_cuda');
thsn you will be fine.
Thank you.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGPU Computing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by