Numbapro停止了对gpu的工作

时间:2014-12-08 20:39:42

标签: python cuda numba numba-pro

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

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:

卸载库没有帮助。

2 个答案:

答案 0 :(得分:1)

斯坦,

过去一周我也遇到过类似的问题。我将我的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()

我希望这可能有所帮助。

答案 1 :(得分:0)

虽然它与您当前收到的错误无关,但请注意,调用VectorAdd的代码中的代码中也存在错误。

你有:

C = VectorAdd(A, B, C)

应该是:

C = VectorAdd(A, B)