Hi,
I’ve written a cuda plugin (dynamic library) which is loading another application. I am using dlopen() and dlsym() to use the functions from this plugin. For my application it is very important that any time of using plugin the program get a new handle for the dynamic library (the library file will be subsequently modified).
Therefore after the using of functions from my plugin I invoke the dlclose(). The invocations dlopen() - dlsym() - dlclose() are occur during my program execution.
If I working on the computer with NVIDIA driver 256.35 (CUDA 3.0 or 3.1) I have a memory leak (I use in my plugin cudaMemGetInfo() calling for the diagnostics).
If I working on the computer with NVIDIA driver 195.36.15 (CUDA 3.0) I have the error after some time of the program execution: “NVIDIA: could not open the device file /dev/nvidia0 (Too many open files).â€
If I don’t use the dlclose() invocation the program is working fine, but in this case I can’t replace the plugin on a new one’s during my program execution .
I’ve found the similar example on CUDA SDK: matrixMulDynlinkJIT. I’ve done small correction in the code. In particular, in the file cuda_drvapi_dynlink.c I’ve corrected cuInit() function:
CUDADRIVER CudaDrvLib = NULL;
CUresult CUDAAPI cuInit(unsigned int Flags)
{
//CUDADRIVER CudaDrvLib;
CUresult result;
int driverVer;
And in the file matrixMulDynlinkJIT.cpp I’ve added a loop in the main() function:
int main(int argc, char** argv)
{
printf(“[ %s ]\n”, sSDKsample);
while (1) {
// initialize CUDA
CUfunction matrixMul = NULL;
cutilDrvSafeCallNoSync(initCUDA(&matrixMul, argc, argv));
.....
}//while (1)
cutilExit();
}
So, I have the same problem like in my program (after some time execution): “NVIDIA: could not open the device file /dev/nvidia0 (Too many open files).â€
But when I comment out the dlclose() in the cuda_drvapi_dynlink.c file – everything works fine
I’ve found the similar example on CUDA SDK: matrixMulDynlinkJIT. I’ve done small correction in the code. In particular, in the file cuda_drvapi_dynlink.c I’ve corrected cuInit() function:
CUDADRIVER CudaDrvLib = NULL;
CUresult CUDAAPI cuInit(unsigned int Flags)
{
//CUDADRIVER CudaDrvLib;
CUresult result;
int driverVer;
And in the file matrixMulDynlinkJIT.cpp I’ve added a loop in the main() function:
int main(int argc, char** argv)
{
printf(“[ %s ]\n”, sSDKsample);
while (1) {
// initialize CUDA
CUfunction matrixMul = NULL;
cutilDrvSafeCallNoSync(initCUDA(&matrixMul, argc, argv));
.....
}//while (1)
cutilExit();
}
So, I have the same problem like in my program (after some time execution): “NVIDIA: could not open the device file /dev/nvidia0 (Too many open files).â€
But when I comment out the dlclose() in the cuda_drvapi_dynlink.c file – everything works fine