How do I solve an unknown error using GPU Array? ("Error using gpuArray An unexpected error occurred on the device. The error code was: UNKNOWN_ERROR."))
5 views (last 30 days)
Show older comments
I am making a large matrix, and sending it to the GPU to be computed, included below. However, when trying to run on one laptop (Dell XPS 9500 w/ GTX 1650 ti), it errors out on the second to last line, printing:
Error using gpuArray
An unexpected error occurred on the device. The error code was: UNKNOWN_ERROR.
I tried this on a borrowed laptop (Inspiron 16 plus w/ RTX 3060), and could only run it once before needing to restart Matlab to clear the error. I also tried making the matrix without having it be sparse to the same result. All my drivers are up to date. N and n below are values in the ~2000-4000 range, so it's a large matrix to be sure. Ignoring the likely inefficiencies and faux pas, help?
%% Make large A
% Split up L/R
A_left = sparse(A_ext(1:end/2,:));
A_right = sparse(A_ext(end/2+1:end,:));
N = size(A_left,1); % N = meas pix
n = size(A_left,2); % n = scene pix
A_large_temp = zeros(6*N,4*n);
YUV = [1 0 0 1.1398346;...
1 0 -0.3946461 -0.5805942;...
1 0 2.0321119 0;...
0 1 0 1.1398346;...
0 1 -0.3946461 -0.5805942;...
0 1 2.0321119 0];
for i = 1:6
for j = 1:4
if i <= 3
A_large_temp((i-1)*N+1:i*N,(j-1)*n+1:j*n) = YUV(i,j)*A_left;
else
A_large_temp((i-1)*N+1:i*N,(j-1)*n+1:j*n) = YUV(i,j)*A_right;
end
end
end
A_large = gpuArray(sparse(A_large_temp));
clear A_large_temp
1 Comment
Joss Knight
on 14 Aug 2021
This sort of error is certainly not intended behaviour, but is the occasional consequence of NVIDIA libraries running out of memory during operation, or of long-running kernels being interrupted by the operating system. In this case creating a sparse array on the GPU involves some work converting between CSC and CSR representations, essentially transposing, and it's certainly conceivable that your card either doesn't have enough resources or is being disrupted by graphics commands.
To troubleshoot, start by ensuring you are not using your card to drive your display. Then follow these instructions to disable kernel timeouts (assuming you are on Windows). Then if the problem still occurs, reduce the problem size until it starts working. If the problem only occurs after a certain matrix size, it is to do with having insufficient memory.
Answers (0)
See Also
Categories
Find more on GPU Computing in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!