【问题标题】:When I try to run modules from pycuda, I get the error: "No module named 'pycuda._driver'"当我尝试从 pycuda 运行模块时,出现错误:“没有名为 'pycuda._driver' 的模块”
【发布时间】: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”时,我认为我应该拥有所有文件夹。

【问题讨论】:

    标签: python pycuda


    【解决方案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

    【讨论】:

    • 以下链接打不开
    • @MMH 他们可能只是将其重新定位在其网站上的其他位置。只需谷歌“安装 pycuda anaconda IBM”
    猜你喜欢
    • 2015-08-04
    • 2018-12-18
    • 2011-08-01
    • 1970-01-01
    • 2021-01-27
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多