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

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的代码因相同的“在CUDA_ERROR_NO_DEVICE中调用cuInit结果”而开始失败。

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

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

导入numbapro
   numbapro.check_cuda()

我希望这会有所帮助。

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

10-12 18:15