Anaconda安装pycuda

时间:2018-10-29 09:57:52

标签: python gpu pycuda

我正在尝试在具有Windows 10 64位元的计算机上安装pycuda,我安装了具有Python 3.5 64位元的GPU Toolkit 9.1和Anaconda 4.2。我使用预编译的软件包安装了pycuda:

pycuda‑2017.1.1 + cuda9185‑cp35‑cp35m‑win_amd64.whl

Anaconda安装中的安装未标记任何错误,但是当我尝试运行一个简单的示例时,导入出现问题:

Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycuda.driver as cuda
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
ImportError: numpy.core.multiarray failed to import

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Anaconda3\lib\site-packages\pycuda\driver.py", line 5, in <module>
    from pycuda._driver import *  # noqa
SystemError: <class 'ImportError'> returned a result with an error set

有什么想法吗?

更新:

我解决了我的第一个问题,将cuda库的lib目录添加到我的路径:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\lib

但是现在我遇到了这个错误:

Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycuda.driver as cuda
>>> import pycuda.autoinit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Anaconda3\lib\site-packages\pycuda\autoinit.py", line 5, in <module>
    cuda.init()
pycuda._driver.Error: cuInit failed: unknown error

已解决

我尝试安装Cudatoolkit 9.2,并添加

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\lib

路径,更新我的nvidia驱动程序,并安装pycuda pycuda‑2018.1 + cuda92148‑cp35‑cp35m‑win_amd64.whl

现在我的cuda代码可以正常工作了。

0 个答案:

没有答案