CUDA 主机到设备(或设备到主机)memcpy 操作以及在同一显卡上使用 OpenGL 渲染图形的应用程序

发布于 2024-08-10 14:20:16 字数 239 浏览 2 评论 0原文

我已在 CUDA 论坛中发布了我的问题,但不确定在此处发布链接以获取更多想法是否合适,以防两个论坛之间存在大量不同的受众。链接位于此处。对于给您带来的任何不便,我深表歉意,并感谢对此问题的任何评论,因为我还没有收到有关特定 CUDA 内存访问和管理问题的一些细节的回复。提前致谢。

I have posted my problem in the CUDA forums, but not sure if it's appropriate to post a link here for more ideas in case there are significant number of different audiences between the two forums. The link is here. I apologize for any inconvenience and appreciate any comments on this question, as I haven't heard back yet on some specifics of a particular CUDA memory access and management problems. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

来世叙缘 2024-08-17 14:20:16

如果没有看到更多代码,我不确定这是否相关,但是 CudaObj 的析构函数是从哪里调用的?

你说:

但是,如果我这样做,我会在调用 cudaFree() 的 CudaObj 析构函数行中退出应用程序时遇到错误。这会导致CUDA上下文的清理代码之后的内存清理代码由于错误而没有被执行,留下一堆内存泄漏。

在描述了如何将 cuda 设置内容更改为 thread2 main 函数的开头之后。如果您从不同的线程调用 CudaObj 上的析构函数,则执行 cudaFree 清理将出错,原因与您必须将 cuda 初始化移至线程 2 中相同。听起来您已经知道这一点,但 cuda 上下文特定于进程中的单个线程。根据文档,不支持在不同线程中进行清理,尽管我自己从未尝试过。
希望这有帮助

I'm not sure if this is relevant without seeing more of your code but where is CudaObj's destructor being called from?

you said:

However, if I do it this way, I run into errors exiting the application in the line of CudaObj's destructor where cudaFree() is called. This causes the memory cleanup code after CUDA context's cleanup code not being executed due to the error, leaving behind a mess of memory leaks.

After your description of how you changed the cuda setup stuff to be in the beginning of thread2's main function. If you're calling the destructor on CudaObj from a different thread then doing the cudaFree cleanup will be in error for the same reason that you had to move the cuda initialization into thread 2. It sounds like you know this already, but the cuda context is specific to a single thread in your process. Cleaning up in a different thread is not supported according to the documentation, though I've never tried it myself.
Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文