我已经使用 pip
安装了 PyCUDA
。我在两台电脑上试过了。
一个是全新安装的 Python 3.7.1
,另一个是 Python 3.6.5
。
使用 PuCUDA
后一切都失败了,没有错误消息。
The minimum example is this:
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")
除非我删除 pycuda.autoinit
,否则这不会打印任何内容。
Another example would be using
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 失败但没有任何报告。
我的配置:
+--------------------+--------------------+ | 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
我注意到这是一个 common problem但没有解决方案。
最佳答案
我不确定这是否对您有帮助,但类似的问题已解决
重新安装 cuda
(使用 anoconda
)。
如果你需要它,你可以通过 conda
控制台安装它
conda install -c anaconda cudatoolkit
并检查它是否运行良好,
输入numba -s
希望对你有帮助
关于python - 使用 PyCUDA 后无输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53718293/