CUDA in Matlab - Mex files work, then stop Using CUDA in Matlab, mex files shown to work start throw

So I’ve been messing around with CUDA looking at different amounts of acceleration I can get in Matlab. So far, I have used Jacket and a convolution mex file I’ve found online. It was originally an example written by NVIDIA, wrapped in Mex code. Jacket is an “add-on” to Matlab which allows for Matlab to do operations over the GPU rather than CPU through use of CUDA. I don’t want to explain how it works as I am not 100% sure of what I know.

The mex file works great, and has significant improvements over regular Matlab, however the second I use any form of Jacket (such as an m file that uses jacket) my mex files start throwing errors. More specifically, my CUDA error checks are intercepting errors, and so far these errors seem very random.

The first CUDA error I got was “invalid argument” with an execution configuration of <<<(1, 1, 1), (16, 12, 1)>>>. After retstarting Matlab, the mex file was working great again (even ones I’ve personally modified). I typed “ginfo”, which is a Jacket function that gives information on your gpu, and started getting “invalid resource handle.”(same configuration) Any idea on what could be causing these errors? Thanks!

Hi JustSpiffy,

Thanks for the post. I’ve responded to this on the AccelerEyes forums, here:…p?f=7&t=394



I bet cudaSetDevice is being called after a context already exists.