CUDA_ERROR_LAUNCH_FAILED when using "gather" function

1 次查看(过去 30 天)
Dear all,
I created two cuda functions, each one in a separated .cuh file, that are called from my main .cu program. I am trying to call then inside my Matlab code and everything seems to work fine, until I call the "gather" function, in order to get the variable back to the cpu. It gives me the following error message:
Error using gpuArray/gather An unexpected error occurred during CUDA execution. The CUDA error was: CUDA_ERROR_LAUNCH_FAILED
And this is the only message that Matlab returns to me. The strange thing is that if I call just one function, it works fine. The problem arises if I call the two functions sequentially and try to gather the resulting vector from the graphics card. Here is my example file:
clear all; clc;
kernelK = parallel.gpu.CUDAKernel('femCuda.ptx', 'fem.cuh', 'setK');
kernelKGlobal = parallel.gpu.CUDAKernel('femCuda.ptx', 'fem2.cuh', 'assemblyGlobalStiffness');
nEl = 2;
ndofs = 2;
nNodes = 4;
x = [0. 1. 1. 0.];
y = [0. 0. 1. 1.];
vecE = [1.];
vecNu = [0.];
conect = int32([0 0 1 3 0 1 2 3]);
x = gpuArray(x);
y = gpuArray(y);
conect = gpuArray(conect);
vecE = gpuArray(vecE);
vecNu = gpuArray(vecNu);
K = gpuArray.zeros(36*nEl, 1);
Kglobal = gpuArray.zeros((nNodes*ndofs)*(nNodes*ndofs), 1);
K = feval(kernelK, x, y, conect, vecE, vecNu, nNodes, nEl, nEl, K);
Kglobal = feval(kernelKGlobal, K, nEl, nNodes, conect, nNodes, Kglobal);
If I just use K = feval(kernelK, x, y, conect, vecE, vecNu, nNodes, nEl, nEl, K);, everything works fine. The problem is when I call the two kernels. What can possibly be wrong?
Thank you in advance,
  1 个评论
Joss Knight
Joss Knight 2014-6-16
编辑:Joss Knight 2014-6-16
Can you confirm that the second kernel also works in isolation?
If you put wait(gpuDevice) between your two calls, does it start working?
Can you provide your CUDA code, or a minimal version which reproduces the error?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 GPU Computing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by