gpt4 book ai didi

python - Numbapro 停止在 GPU 上工作

转载 作者:太空宇宙 更新时间:2023-11-03 18:03:03 31 4
gpt4 key购买 nike

我正在尝试运行以下程序:

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 = 32e6

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, C)
vectoradd_time = timer() - start

print "C[:5] = " + str(C[:5])
print "C[-5:] = " + str(C[-5:])

print "VectorAdd took %f seconds" % vectoradd_time


if __name__ == '__main__':
main()

我第一次运行它时效果很好。但后来我尝试安装 nvprof 和一些附加库,从那时起我收到以下错误:

Traceback (most recent call last):
File "test.py", line 6, in <module>
@vectorize(["float32(float32, float32)"], target='gpu')
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/npyufunc/decorators.py", line 68, in wrap
vec.add(fty)
File "/opt/anaconda1anaconda2anaconda3/lib/python2.7/site-packages/numbapro/cudavec/vectorizers.py", line 78, in add
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/decorators.py", line 89, in kernel_jit
kernel.bind()
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/compiler.py", line 234, in bind
self._func.get()
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/compiler.py", line 181, in get
cuctx = get_context()
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/devices.py", line 126, in get_context
return _get_device(devnum=devnum).context
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/devices.py", line 118, in _get_device
_gpustack.push(get_gpu(devnum))
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/devices.py", line 108, in get_gpu
return gpus[i]
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/devices.py", line 34, in __getitem__
return self._gpus[item]
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/devices.py", line 23, in _gpus
self._tls.gpus = self._init_gpus()
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/devices.py", line 28, in _init_gpus
for num in range(driver.get_device_count()):
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/driver.py", line 256, in get_device_count
self.cuDeviceGetCount(byref(count))
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/driver.py", line 201, in __getattr__
self.initialize()
File "/home/matthias/anaconda/lib/python2.7/site-packages/numba/cuda/cudadrv/driver.py", line 182, in initialize
raise CudaSupportError("Error at driver init: \n%s:" % e)
numba.cuda.cudadrv.error.CudaSupportError: Error at driver init:
Call to cuInit results in CUDA_ERROR_NO_DEVICE:

卸载库没有帮助。

最佳答案

上周我也遇到了类似的问题。我将 Anaconda 环境从 2.7 升级到 3.4,并且使用 numbapro 的代码开始失败,并出现相同的“调用 cuInit 结果为 CUDA_ERROR_NO_DEVICE”。

我不确定我的升级是否与您的升级原因相同,但我提到以防万一。 (我还应该提到我在使用 ARM 处理器的 Ubuntu 上。)

我下载了 cuda_6.5.14_linux_aarch64_native.run 安装程序,重新启动到 Ubuntu 命令行,并安装了这些最新的驱动程序。重新启动进入 X 后,我打开 iPython 并成功运行以下命令:

import numbapro
numbapro.check_cuda()

希望这会有所帮助。

关于python - Numbapro 停止在 GPU 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27366495/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com