如果有人仍在寻找答案:
configure.py 生成一个 siteconf.py 文件,其中包含用于编译 pycuda 的 CUDA .lib 文件的路径。但是,它使用了不正确的路径(至少在 Windows 上并使用工具包 V7.5 时)。
现在这可以通过多种方式修复(确保您已经下载了 pycuda 包并在某处解压缩):
1.修改setup.py
这就是罪魁祸首所在。这些是它当前使用的路径:
default_lib_dirs = [
"${CUDA_ROOT}/lib", "${CUDA_ROOT}/lib64",
# https://github.com/inducer/pycuda/issues/98
"${CUDA_ROOT}/lib/stubs", "${CUDA_ROOT}/lib64/stubs",
]
目前 Nvidia 使用 CUDA_PATH 作为环境变量,.lib 文件存储在单独的 x64 或 Win32 文件夹中。您可以将这些路径添加到数组中,也可以删除不正确的路径
default_lib_dirs = ["${CUDA_PATH}/lib/x64", "${CUDA_PATH}/lib/Win32"]
现在运行py configure.py
以生成 siteconf.py 文件。
2.覆盖configure.py生成的设置
如前所述,configure.py 生成 siteconf.py 文件。您可以使用可选参数调用 configure.py 来覆盖默认库文件夹(我们在 setup.py 中定义的)。运行 configure.py --help 后的部分输出
--cudadrv-lib-dir=DIR
Library directories for Cudadrv (default:
${CUDA_PATH}/lib/x64) (several ok)
--cudadrv-libname=LIBNAME
Library names for Cudadrv (without lib or .so)
(default: cuda) (several ok)
--cudart-lib-dir=DIR Library directories for Cudart (default:
${CUDA_PATH}/lib/x64) (several ok)
--cudart-libname=LIBNAME
Library names for Cudart (without lib or .so)
(default: cudart) (several ok)
--curand-lib-dir=DIR Library directories for Curand (default:
${CUDA_PATH}/lib/x64) (several ok)
--curand-libname=LIBNAME
Library names for Curand (without lib or .so)
(default: curand) (several ok)
3.直接修改siteconf.py
最简单的方法。只需运行py configure.py
以生成siteconf.py
具有默认路径的文件,然后编辑该文件。
后来我发现这两个页面都建议这样做:
https ://kerpanic.wordpress.com/2015/09/28/pycuda-windows-installation-offline/
https://wiki.tiker.net/PyCuda/Installation/视窗
完成安装
总结一下,通过运行编译和安装 pycuda:
py setup.py build
py setup.py install
(这将使用之前生成/修改的 siteconf.py 文件)。
而已 :)
(如果您想知道为什么我写下了所有 3 种方法而不是最简单的一种方法,实际上我在弄乱文件后发现了 siteconf.py 和 configure.py 文件default_lib_dirs
。setup.py
两个网站链接也是如此,我在手动解决问题后找到了那些)