MATLAB: Do I receive error: “Unable to recover from kernel exception. error code: 3” when running GPU operations

computingnvidiaparallelParallel Computing Toolboxtoolbox

I am running code on my GPU from MATLAB to test my GPU performance. When I multiply large matrices, I receive an error message:
ERROR: A = rand(2^22, 2^22);
B = rand(2^22, 2^22);
gputimeit(@() A*B);
unable to recover from kernel exception. The application must be closed.
error code: 3 (subcode 2)
An unexpected error occurred during CUDA execution. The CUDA error was: unknown error
Error in parallel.internal.gpu.timeit
Error in gputimeit (line 66)
t = parallel.internal.gpu.timeit(f, num_outputs);

Best Answer

The issue  is caused by the operation on the GPU taking longer than the timeout specified by the Windows operating system. The graphics card is being used for rendering the Windows desktop to the screen as well as direct computations from MATLAB. The Windows Display Driver Model (WDDM) enforces a timeout on GPU operations so that Windows can continue to display the desktop environment responsively. The fact that the issue occurs only for larger matrices, which would take more time to multiply, further supports this conclusion.
This timeout is a limitation of shared-use graphics cards on Windows. There are some potential workarounds. These workarounds are outside the scope of MathWorks Technical Support and are provided as suggestions for further investigation.
  • The system and graphics card may support operating the card in a "compute only" mode known as Tesla Compute Cluster (TCC) mode. Please refer to the documentation for your NVIDIA card for more information.
  • It may be possible to modify the Windows registry to allow your GPU operations to run longer. For more information please refer to the following link: