我使用pip
安装了PyCUDA
。我在两台计算机上尝试过。
一台是全新安装的Python 3.7.1
,另一台是Python 3.6.5
。
在使用PyCUDA
之后,一切都失败了,没有任何错误信息。
最小的示例代码如下:
import sys
import pycuda.driver as cuda
import pycuda.autoinit # <-- Comment in order for `print` to work
if __name__ == '__main__':
print('Print works')
sys.stdout.write("Sys print works")
< p >如果我不删除 pycuda.autoinit
,则不会打印任何内容。< blockquote >另一个例子是使用 printf
:
import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
if __name__ == '__main__':
mod = SourceModule("""
#include <stdio.h>
__global__ void test() {
printf("I am %d.%d\\n", threadIdx.x, threadIdx.y);
}
""")
func = mod.get_function("test")
func(block=(4, 4, 1))
这也没有返回任何输出。
我认为CUDA失败了,但没有任何报告。
我的配置:<br/>
+--------------------+--------------------+ | PC1 | PC2 | +--------------------+--------------------+ | Python 3.6.5 | Python 3.7.1 | | Windows 10 | Windows 10 | | Cuda toolkit 9 | Cuda toolkit 10 | | GeForce GTX 1050 | GeForce GTX 1080 | | Visual Studio 2015 | Visual Studio 2015 | +--------------------+--------------------+
驱动程序:
GeForce Game Ready Driver Version : 418.91 WHQL Release Date : Wed Feb 13, 2019
我注意到这是一个常见问题,但没有解决方案。