开发者

CUDA plugin dlopen

I've written a cuda plugin (dynamic library), and I have a program written in C which uses dlopen() to l开发者_如何学Pythonoad this plugin. I am using dlsym() to get the functions from this plugin. For my application it is very important that any time of loading plugin the program gets a new handle with dlopen() calling (the library file may modified subsequently). Therefore after the using of functions from my plugin I invoke the dlclose(). The invocations dlopen() - dlsym() - dlclose() are occur during my program execution (in the loop).

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 an 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.

Anyone encountered this problem? Thanks.


Nobody wrote plugins on CUDA?

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;

    if (CudaDrvLib != NULL) {
      dlclose (CudaDrvLib);
      CudaDrvLib = NULL;
    }
     .......
}

And in the file matrixMulDynlinkJIT.cpp I've added 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 – all works fine

I can't understand this behavior... Any ideas?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜