GPU Coder used, but got error: Error generated while running CUDA-enabled program: [700,cudaE​rrorIllega​lAddress]

26 Ansichten (letzte 30 Tage)
I'm using GPU coder to accelerate N-D interpolation function interpn().
Everything worked fine when my problem scale was small, i.e. interpolating in 1-D or 2-D dimensions. But when I throw a larger problem, of 5-D interpolation to it, MATLAB threw the following error message:
Error generated while running CUDA-enabled program: [700,cudaErrorIllegalAddress] an
illegal memory access was encountered. To generate additional debugging information,
enable the 'SafeBuild' GPU code generation option.
I followed the error message suggestion above and added the 'SafeBuild' GPU code generation option, and got the following error instead:
Error generated while running CUDA-enabled
program: [46,cudaErrorDevicesUnavailable] all
CUDA-capable devices are busy or unavailable
I know that when I wasn't using GPU Coder, the code still worked but kind of slow. But now when GPU coder is enabled, it is not working. I have NVIDIA RTX 2080ti with 11G memory. When I was using CPU to do the calculation, the problem took 1 hour and peak RAM use was around 40GB out of 64GB RAM. Could this error be because I ran out of GPU memory by establishing my problem too large? How can I tell if this is the case?
OK update: I rebooted my Windows PC, and ran the same program again, the following error showed instead:
Error generated while running CUDA-enabled
program: [2,cudaErrorMemoryAllocation] out of
I think this confirms that indeed my problem is causing GPU to run out of memory just to start the problem. Now I know the problem, is there any suggestions how to split the problem for interpn? Thanks!
  3 Kommentare
First am 7 Dez. 2021
hi may i know the solution ? i met same error of cuda out of memory but its quite weird. Same code can run cpu1+gtx980 but error above when i run on cpu2+gtx980 and cpu2 has more much more cores and memory than cpu1.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Gautam am 19 Jan. 2023
Bearbeitet: Gautam am 19 Jan. 2023
The error is most likely that a matrix is growing beyond it's intended size. Take a careful look at your code to analyze which matrix is growing beyond the intended value.
Growing size matrices are silently handled by MATLAB, but the coder generates CUDA C which does not handle growing sizes so it is mostly seg-faulting when you run the generated code.
Try running your code in MATLAB and check if every matrix at the end of its computation is having the intended size.
Also, when you run into a "cudaErrorIllegalAddress" you have to restart MATLAB and run your code. This is because, when the coder runs the generated code for the first time, it creates a CUDA context and it reuses the same context in the subsequent runs till the MATLAB application is closed. Now, when you encounter a seg-fault when running the generated code, the context gets corrupted, MATLAB doesn't know about it and so it tries to run the same context in the next run, which will fail. So the solution is to restart MATLAB.


Mehr zu Get Started with GPU Coder finden Sie in Help Center und File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by