如何在Windows上部署CUDA程序?

发布于 2024-11-29 01:23:52 字数 351 浏览 0 评论 0原文

我有一个链接到 cudacublascudart 的程序。

有没有一种方法可以在不强制用户安装最新的 nvidia 驱动程序的情况下部署它?

当我将提到的 dll 复制到启动路径中时,程序无法启动并抱怨 nvcuda.dll 中不存在程序。即使我也提供这个,该程序的行为也很奇怪。如果安装了最新的驱动程序,一切正常。

相关问题...我如何检查cuda是否受支持(+最新),如果不是这种情况,则回退到我的情况BLAS/LAPACK?如果我提供 dll 程序。行为不端,如果我不提供它们,它甚至可能无法启动。

谢谢!

I have a program linking against cuda, cublas, and cudart.

Is there a way to deploy it without forcing the users to install the very latest nvidia drivers?

When I just copy the mentioned dlls into the startup path, the program doesn't start and complains about a non-existent procedure in nvcuda.dll. Even if I supply this one as well, the program behaves strangely. If the most recent drivers are installed, everything works fine.

Related question ... how can I check that cuda is supported (+ up to date) and if this is not the case fallback into my case BLAS/LAPACK? If I provide the dlls the prog. misbehaves, if I don't supply them it might not even start.

Thx!

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

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

发布评论

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

评论(1

泅渡 2024-12-06 01:23:52

您是否尝试不链接 CUDA dll,而是动态加载并调用 cudaGetDeviceCount()?像这样:

typedef cudaError_t (*FnGetDeviceCount )    (   int *   count    ) ;
HMODULE hCuda=LoadLibrary("cudart32_40_17.dll");
if( !hCuda ) return ; // ERROR: cannot load dll, DllMain must have failed because cudart only depends on Kernel dll implicitly. Or cannot find dll in curent directory or in the path.
FnGetDeviceCount fnGetDeviceCount=(FnGetDeviceCount)GetProcAddress(hCuda, "cudaGetDeviceCount");
if( !fnGetDeviceCount) return; // ERROR: cudart has no entry point for cudaGetDeviceCount ?!
int count = 0;
if( cudaSuccess != (*fnGetDeviceCount)(&count) ) return ;// ERROR: we don't wanna use CUDA if even device enumeration fails
if( !count ) return; // FALLBACK: CUDA has no devices, don't try to use it, fallback to some other BLAS

这很不方便,因为您不能只链接到 cudart 或其他库,但它可能允许您回退到 BLAS,而不会导致用户看到可怕的启动错误。免责声明:我没有测试甚至编译此代码,如果您使用它并且它有效,请告诉我们:)

此线程 建议您必须从特定版本的 CUDA 工具包(例如 cudart64_40_17.dll)重新分发 dll,这样就可以了。

Did you try not to link against CUDA dlls, but load dynamically and call cudaGetDeviceCount()? Like this:

typedef cudaError_t (*FnGetDeviceCount )    (   int *   count    ) ;
HMODULE hCuda=LoadLibrary("cudart32_40_17.dll");
if( !hCuda ) return ; // ERROR: cannot load dll, DllMain must have failed because cudart only depends on Kernel dll implicitly. Or cannot find dll in curent directory or in the path.
FnGetDeviceCount fnGetDeviceCount=(FnGetDeviceCount)GetProcAddress(hCuda, "cudaGetDeviceCount");
if( !fnGetDeviceCount) return; // ERROR: cudart has no entry point for cudaGetDeviceCount ?!
int count = 0;
if( cudaSuccess != (*fnGetDeviceCount)(&count) ) return ;// ERROR: we don't wanna use CUDA if even device enumeration fails
if( !count ) return; // FALLBACK: CUDA has no devices, don't try to use it, fallback to some other BLAS

It's inconvenient because you can't just link against cudart or other libraries, but it may allow you to fallback to BLAS without user seeing horrible startup errors. Disclaimer: I didn't test or even compile this code, please let us know if you use it and it works :)

This thread suggests you have to redistribute dlls from your particular version of the CUDA toolkit (e.g. cudart64_40_17.dll), so that's fine.

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