Skip to main content
 首页 » 编程设计

python之Pycuda 编译错误

2025年04月02日16think

我在安装了 python 2.7(32 位)和安装了 cuda 7.5 whl 的 pycuda 的 Windows 机器上。我在运行示例程序来测试 pycuda 时出错。

Traceback (most recent call last): 
  File "C:\Users\newbie\Desktop\roo.py", line 82, in <module> 
    """) 
  File "C:\Python27\lib\site-packages\pycuda\compiler.py", line 265, in __init__ 
    arch, code, cache_dir, include_dirs) 
  File "C:\Python27\lib\site-packages\pycuda\compiler.py", line 255, in compile 
    return compile_plain(source, options, keep, nvcc, cache_dir, target) 
  File "C:\Python27\lib\site-packages\pycuda\compiler.py", line 137, in compile_plain 
    stderr=stderr.decode("utf-8", "replace")) 
pycuda.driver.CompileError: nvcc compilation of c:\users\newbie\appdata\local\temp\tmplluyeq\kernel.cu failed 
[command: nvcc --cubin -arch sm_35 -m32 -Ic:\python27\lib\site-packages\pycuda\cuda kernel.cu] 
[stdout: 
kernel.cu 
 
] 
[stderr: 
'C:\Program' is not recognized as an internal or external command, 

可能的解决方案是什么。 请帮忙 !

请您参考如下方法:

由于知识有限,我的第一个猜测是在包含 C:\Program Files\anything 的路径中 Program 之后的空白没有得到正确处理。

编辑:包括独立于链接的解决方案。

您可能需要转义文件路径中的空格。但是,由于主要使用 linux,我不确定 Windows 斜线。示例 C:/Program\Files/foo/bar.exe

另一种方法可能是在路径周围加上引号。 C:\"Program files"\foo\bar.exe 或 "C:\Program files\foo\bar.exe"

第三种选择是用十六进制替换空格,例如 %20 比如 C:\Program%20files\foo\bar.exe。在 C++ 中,我认为你可以用\u0020 替换空格。因此,这种替换方法也可能是一种途径。

这篇文章的建议答案可能会有帮助:

https://superuser.com/questions/432980/how-to-call-a-program-that-contains-space-in-filename enter link description here