CUDA_ERROR​_CONTEXT_I​S_DESTROYE​D when calling gpuArray after simulations on GPU

조회 수: 6 (최근 30일)
I run some simulations with MCXLab, a toolbox using the GPU, that perform correctly. Then I want to do some matrix operations on the extracted data, and I do that iteratively. Here is a simplified code:
for ii=1:N
MCXLab simulations => OK
D=some matrix of size (N);
D=gpuArray(D);
update simulation parameters
end
The weird thing is that it performs ok for ii=1 but throws this error at D=gpuArray(D);:
"Error using gpuArray
Encountered unexpected error during CUDA execution. The CUDA error was:
CUDA_ERROR_CONTEXT_IS_DESTROYED". for the second iteration.
Once the error is thrown, launching again the entire code gives the same error at ii=1 (but MCXlab simulations are done correctly).
Trying reset(gpuDevice()) makes matlab crash ('Matlab stopped working and needs to close') with the warning
"Warning: Encountered unexpected error during CUDA execution. The CUDA error was:
CUDA_ERROR_CONTEXT_IS_DESTROYED "
The code is running on Windows, Matlab R2021a, with a Nvidia Quadro P2000 GPU. MCXLab is a Mex open source Light simulator.
The error happens whetever the size N (even a scalar), with single or double precision.
  댓글 수: 2
William
William 2023년 3월 14일
I seem to be having the same issue, after using mcxlab any further computations on the GPU throw back this error!
Charlotte Constans
Charlotte Constans 2023년 3월 14일
I just solved this problem by updating mcxlab with the latest compiled code (https://github.com/fangq/mcx). You just need reset(gpuDevice) between mcxlab simulations and further GPU calculations.

댓글을 달려면 로그인하십시오.

답변 (1개)

Joss Knight
Joss Knight 2023년 3월 10일
Probably MCXLab is doing something bad to your GPU. Try adding wait(gpuDevice) after your MCXLab code.
  댓글 수: 11
Joss Knight
Joss Knight 2023년 3월 13일
So you kept the code to call gpuDevice() before you do anything else, restarted MATLAB, and the issue still happens?
I'm afraid you'll have to talk to the MCXLab forums. This is an issue caused by MCXLab, either resetting the device or doing something illegal internally. You could tell them that calling MCXLab with given inputs put the device into a bad state and MATLAB can no longer use it.
Charlotte Constans
Charlotte Constans 2023년 3월 14일
Yes it still happens.
Thank you very much for your help, I will contact the MCXLab team.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by