我运行了我在 CUDA Python 介绍页面上阅读的这段代码:-
import numpy as np
from timeit import default_timer as timer
from numbapro import vectorize
@vectorize(["float32(float32, float32)"], target='gpu')
def VectorAdd(a, b):
return a + b
def main():
N = 32000000
A = np.ones(N, dtype=np.float32)
B = np.ones(N, dtype=np.float32)
C = np.zeros(N, dtype=np.float32)
start = timer()
C = VectorAdd(A, B)
vectoradd_timer = timer() - start
print("C[:5] = " + str(C[:5]))
print("C[-5:] = " + str(C[-5:]))
print("VectorAdd took %f seconds" % vectoradd_timer)
if __name__ == '__main__':
main()
我在终端上收到以下错误:-
dtn34@dtn34-ubuntu:~/Python$ python asd.py
Traceback (most recent call last):
File "asd.py", line 3, in <module>
from numbapro import vectorize
ImportError: No module named numbapro
它应该使用 gpu 运行代码,但我得到了那个错误。我已经安装了 anaconda,更新了 conda,使用 conda 安装了加速,安装了 cudatoolkit,使用 conda 安装了 numba。我尝试使用 python2 和 python3 编译它
我该怎么办?