CUDA 插件 dlopen
我编写了一个 cuda 插件(动态库),并且我有一个用 C 编写的程序,它使用 dlopen() 来加载该插件。我正在使用 dlsym() 从该插件获取函数。对于我的应用程序来说,任何时候加载插件时,程序都会通过 dlopen() 调用获得新的句柄(库文件可能随后会被修改),这一点非常重要。 因此,在使用我的插件中的函数之后,我调用 dlclose()。调用 dlopen() - dlsym() - dlclose() 发生在我的程序执行期间(在循环中)。
如果我在使用 NVIDIA 驱动程序 256.35(CUDA 3.0 或 3.1)的计算机上工作,则会出现内存泄漏(我在插件 cudaMemGetInfo() 中使用调用诊断)。 如果我在使用 NVIDIA 驱动程序 195.36.15 (CUDA 3.0) 的计算机上工作,程序执行一段时间后会出现错误:“NVIDIA:无法打开设备文件 /dev/nvidia0(打开的文件太多)。”
如果我不使用 dlclose() 调用,程序运行正常,但在这种情况下,我无法在程序执行期间将插件替换为新插件。
有人遇到过这个问题吗? 谢谢。
I've written a cuda plugin (dynamic library), and I have a program written in C which uses dlopen() to load 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没人写CUDA插件吗?
我在 CUDA SDK 上找到了类似的示例:
matrixMulDynlinkJIT
。我对代码做了一些小修正。特别是,在文件cuda_drvapi_dynlink.c
中,我更正了cuInit()
函数:并在文件
matrixMulDynlinkJIT.cpp
中添加了在main()
函数中循环:所以,我遇到了与我的程序相同的问题(执行一段时间后):“NVIDIA:无法打开设备文件 /dev/nvidia0(打开的设备文件太多)文件)”。
但是当我注释掉
cuda_drvapi_dynlink.c
文件中的dlclose()
时 – 一切正常,我无法理解这种行为......
有什么想法吗?
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 filecuda_drvapi_dynlink.c
I've correctedcuInit()
function:And in the file
matrixMulDynlinkJIT.cpp
I've added loop in themain()
function: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 thecuda_drvapi_dynlink.c
file – all works fineI can't understand this behavior...
Any ideas?