When I try to run modules from pycuda, I get the error: "No module named 'pycuda._driver'"
When I try to run modules from pycuda, I get the error: "No module named 'pycuda._driver'"
我想 运行 我从这个网站上下来的代码 - 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 行,位于
来自 pycuda._driver 导入 * # 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" 时,我认为我应该拥有所有文件夹。
根据您的 OS 确保您已在正确的 cuda 库路径上配置 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
我想 运行 我从这个网站上下来的代码 - 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 行,位于 来自 pycuda._driver 导入 * # 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" 时,我认为我应该拥有所有文件夹。
根据您的 OS 确保您已在正确的 cuda 库路径上配置 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