问题描述
我使用一个使用CUDA的matlab(Linux 64bit)中的MEX文件。代码编译和执行很好,但是当我想卸载mex(例如重新编译它或matlab退出时),matlab立即崩溃,没有任何消息和空转储。
我可以把它减少到最小的工作示例:
MEX cpp文件:
#include< stdint.h>
#includemex.h
externCvoid cudaTest();
void mexFunction(
int nlhs,mxArray * plhs [],
int nrhs,const mxArray * prhs [])
{
cudaTest ;
}
CUDA使用NVCC编译的文件:
void cudaTest(){
float * d_test = NULL;
cudaMalloc((void **)& d_test,10000 * sizeof(float));
cudaFree(d_test);
}
虽然我的真实程序总是崩溃,总是可再现。有时它会崩溃有时不..
我认为这解决了我的问题:
http://www.mathworks.de/matlabcentral/answers/45307
I have been trying to figure this out for quite some time.
I use a MEX file in matlab (Linux 64bit) which uses CUDA. The code compiles and executes fine but when I want to unload the mex (e.g. to recompile it or when matlab exits), matlab crashes immediately without any message and with an empty dump.
I was able reduce 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 with NVCC:
void cudaTest() {
float* d_test = NULL;
cudaMalloc((void**) &d_test, 10000 * sizeof(float));
cudaFree(d_test);
}
While with my real program it always crashes, with this minimal example it is not always reproducible. Sometimes it does crash sometimes not..
I think this solved my problem:
http://www.mathworks.de/matlabcentral/answers/45307
这篇关于卸载使用CUDA内存的mex文件时,MATLAB崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!