clear mex causes segmentation fault when using cuda RT API
Mostra commenti meno recenti
Hi all,
I have a mex function with CUDA code in it so that I can take advantage of my Quadro 4000 gpu (Driver version 4.2 / Runtime version 4.2) on my 64-bit linux machine.
Any time I make any call to a CUDA Runtime API function (cudaMalloc, cudaMemset, cudaMemcpy, etc.), I get a segmentation fault if I clear mex (or clear all).
Here is my simple .cu code:
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
// Allocate and free one float on GPU memory
float *a = NULL;
cudaMalloc((void **)a, sizeof(float));
cudaFree(a);
// cudaDeviceReset();
}
After compiling the .cu to .cpp using nvcc and then making myMexFunction.mexa64 with mex, I call my function in MATLAB2012a:
>> myMexFunction;
>> clear all
>> Segmentation fault (core dumped)
One workaround I've found is calling "cudaDeviceReset()" at the end of my mex function. It doesn't seem like resetting the device every time I call my function should be necessary though.
Interestingly, calls to the Driver API have no such issues.
Has anyone encountered this before?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su GPU CUDA and MEX Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!