【发布时间】:2020-09-04 13:08:11
【问题描述】:
我正在尝试让 cupy 使用此处文档中的 convolve https://docs.cupy.dev/en/latest/reference/generated/cupy.convolve.html
>>> import cupy as cp
>>> b = cp.array([0,0,0,1,0,0,0,1])
>>> cp.convolve(b, cp.ones(3), 'same') / 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'cupy' has no attribute 'convolve'
所以在 numpy 上卷积似乎可以工作,但在 cupy 上却不行。
>>> import numpy as np
>>> a = np.array([0,0,0,1,0,0,0,1])
>>> np.convolve(a, np.ones(3), 'same') / 3
array([0. , 0. , 0.33333333, 0.33333333, 0.33333333,
0. , 0.33333333, 0.33333333])
虽然像 add 之类的基本功能可以与 cupy 一起使用。
>>> cp.add(b, b)
array([0, 0, 0, 2, 0, 0, 0, 2], dtype=int32)
设置:
- Windows 10
- Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
- cuda 11.0.3 451.82
- cuDNN 11.0 x64 v8.0.3.33
- cuTENSOR 1.2.0
点:
- numpy-1.19.1
- cupy-cuda110-7.8.0
- optuna-2.0.0
我全新安装了 Python 和 cuda,...,但这并没有解决问题。 我现在不知道还可能缺少什么。据我了解是cupy,只是numpy在gpu上处理的,所以numpy的每个函数都应该在cupy中。
【问题讨论】:
-
我可能已经发现了最新文档的问题,而我的 Cupy 版本是 7.8.0,其中没有提到 convolve。我看看能不能升级到那个。
标签: python python-3.x numpy cupy