I have been trying to figure this out for some time.
I am using a MEX file in Matlab (Linux 64bit) which uses CUDA. The code compiles and runs fine, but when I want to unload mex (for example, to recompile it or when Matlab comes out), Matlab will immediately work without any message and with an empty dump.
I was able to shorten it to a minimal working example:
MEX cpp file:
#include <stdint.h> #include "mex.h" extern "C" void cudaTest(); void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { cudaTest(); }
CUDA file compiled using NVCC:
void cudaTest() { float* d_test = NULL; cudaMalloc((void**) &d_test, 10000 * sizeof(float)); cudaFree(d_test); }
As long as my real program always crashes, this minimal example does not always play. Sometimes it works sometimes.
source share