Debugging CUDA in Matlab without having to restart
8 ビュー (過去 30 日間)
古いコメントを表示
Every time I try to launch a CUDA kernel, if the kernel crashes, it seems unrecoverable and I have to restart Matlab. First, the kernel will crash and I'll get this generic error message:
Error using gpuArray/gather
An unexpected error occurred during CUDA execution. The CUDA error was:
CUDA_ERROR_UNKNOWN
Not helpful certainly but fine, I'll debug my code. But the error is fatal for Matlab: On my next attempt to merely construct the kernel I get
Error using parallel.gpu.CUDAKernel
An error occurred during PTX compilation of <image>.
The information log was:
<No information>
The error log was:
<No information>
The CUDA error code was: CUDA_ERROR_UNKNOWN.
It also fails to execute a kernel if I supply a pre-built one. My googling has indicated that
>> reset(gpuDevice(1))
will reset things (I have a single GPU, nVidia 650m) but when I do that Matlab segfaults and does not let me continue.
Is there any way to recover from a CUDA crash? Surely it's not necessary to restart Matlab every time a CUDA kernel crashes?
Edit: This is on Windows 8. On a Linux system with a Tesla K20X the same code runs with no problem. The kernel is compiled with
>> !nvcc my_kernel.cu -ptx
in either case.
3 件のコメント
Vincent Roberge
2017 年 4 月 20 日
I have the exact same problem using Matlab 2017a. If I call a CUDA kernel with an error, the GPU device becomes busy or unavailable and I need to restart Matlab to use it again. This is really annoying.
covariant_cat
2017 年 10 月 20 日
編集済み: covariant_cat
2017 年 10 月 20 日
Same issue here (2017a). This issue makes debugging CUDA in matlab really annoying. Really hope this to be fixed. I'm surprised that this doesn't get fixed after so many years. Without good support of CUDA, more and more people will switch to python for scientific computing (and deep learning). Mathworks should pay more attention to this.
回答 (1 件)
Joss Knight
2017 年 12 月 26 日
If you crash your card, you often need to reload the driver, in much the same way that if a program segfaults, it has to be restarted. Any number of things could go wrong but for the sake of argument let's say the GPU memory containing your kernel instructions has been trashed and is unrecoverable except by being reloaded.
The way to reload the driver is to restart MATLAB. There isn't really any other way to do it because that's the way OSs work.
So really you just need to stop thinking of your CUDA kernel as isolated from the MATLAB executable. When you write your own binaries, whether they be MEX functions or CUDAKernels, you put the entire MATLAB application at risk of your bugs.
3 件のコメント
Walter Roberson
2017 年 12 月 27 日
The overhead for setting up a separate process and communicating with it is somewhat high. When using a shared gpu instead of a tesla class gpu set to dedicated mode, the overhead would typically be an unacceptable burden.
Joss Knight
2018 年 1 月 3 日
If you want to do that, start a parallel pool and use parfeval to run your code in your parallel process. If it crashes your card, your client process will be fine.
参考
カテゴリ
Help Center および File Exchange で GPU Computing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!