【发布时间】:2019-06-26 14:28:02
【问题描述】:
我想运行我从这个站点下载的代码 - https://documen.tician.de/pycuda/tutorial.html - 就是下面的内容。
import pycuda.gpuarray as gpuarray
import pycuda.driver as cuda
import pycuda.autoinit
import numpy
a_gpu = gpuarray.to_gpu(numpy.random.randn(4,4).astype(numpy.float32))
a_doubled = (2*a_gpu).get()
print(a_doubled)
print(a_gpu)
基本上,对于“import pycuda.driver as cuda”这一行,我收到错误消息:
文件“C:\Users\David\Anaconda3\lib\site-packages\pycuda\driver.py”,第 5 行,在 from pycuda._driver import * # noqa
ModuleNotFoundError: 没有名为“pycuda._driver”的模块
这是有道理的,因为当我查看驱动程序文本文件时,我会看到以下几行
try:
from pycuda._driver import * # noqa
except ImportError as e:
if "_v2" in str(e):
from warnings import warn
warn("Failed to import the CUDA driver interface, with an error "
"message indicating that the version of your CUDA header "
"does not match the version of your CUDA driver.")
raise
实际上我的 pycuda 文件夹中没有名为 _driver 的文本文件。那么我该如何解决这个问题呢?当我在终端中编写“pip install pycuda”时,我认为我应该拥有所有文件夹。
【问题讨论】: