CUDA Error: Illegal Memory Access in MATLAB Code
Afficher commentaires plus anciens
Hi everyone,
I'm encountering a CUDA error in my MATLAB code during the second iteration of a loop. Specifically, the error occurs at the wait(gd); command after calling setConstantMemory(kPAM, 'g_nT_Start', single((i) * Max_T_dim));. The error message is:
Error using parallel.gpu.CUDADevice/wait
Encountered unexpected error during CUDA execution. The CUDA error was:
an illegal memory access was encountered
Here is the relevant part of my code:
kPAM = parallel.gpu.CUDAKernel('PAM.ptx', 'PAM.cu', '_PAM');
kPAM.ThreadBlockSize = [1024,1,1];
kPAM.GridSize = [ceil(struct_GPU.Pix.nTdim/kPAM.ThreadBlockSize(1)),struct_GPU.Pix.nYdim*struct_GPU.Pix.nXdim, struct_GPU.Pix.nZdim];
setConstantMemory(kPAM,'g_nT_Start',single(0));
for i = 1:Lteration
if i == Lteration % Last iteration
last_T_dim = struct_GPU.Pix.nTdim - (Max_T_dim * i);
last_input_Array = gpuArray(single(zeros(last_T_dim, struct_GPU.Pix.nZdim, ...
struct_GPU.Pix.nXdim * struct_GPU.Pix.nYdim)));
assignin('base', 'PAM_txyz_gpu', last_input_Array);
assignin('base', 'PAM_txyz_cpu', last_input_Array);
elseif i > 1
PAM_txyz_gpu = input_Array;
PAM_txyz_cpu = output_Array;
else
PAM_txyz_gpu = input_Array;
PAM_txyz_cpu = output_Array;
end
[PAM_txyz_gpu] = feval(kPAM, PAM_txyz_gpu, RFData_gpu);
setConstantMemory(kPAM, 'g_nT_Start', single((i) * Max_T_dim));
wait(gd);
PAM_txyz_cpu = gather(PAM_txyz_gpu);
wait(gd);
PAM_xyz_cpu = PAM_xyz_cpu + squeeze(sum(PAM_txyz_cpu, 1));
end
clear PAM_txyz_cpu PAM_txyz_gpu last_input_Array input_Array;
reset(gd);
Does anyone have any suggestions on how to resolve this illegal memory access issue?
Thanks in advance!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur GPU Computing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!