我想运行我从该站点下车的代码-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)
基本上,对于行 “进口pycuda.driver作为CUDA”,我得到的错误消息:
文件 “C:\用户\大卫\ Anaconda3 \ lib中\站点包\ pycuda \ driver.py”,第5行,在 从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”时应该拥有所有文件夹。
答案 0 :(得分:1)
取决于您的操作系统,请确保已在正确的cuda lib路径上配置了pycuda。请仔细遵循https://wiki.tiker.net/PyCuda/Installation/Windows。
方法::您似乎想在Anaconda上安装它,因此,我建议您遵循此指南。 https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_PyCUDA_On_Anaconda_For_Windows?lang=en