【问题标题】:Error loading library gpuarray with Theano使用 Theano 加载库 gpuarray 时出错
【发布时间】:2017-09-20 12:38:47
【问题描述】:

我正在尝试运行 this script 来测试 Theano 对我的 GPU 的使用并得到以下错误:

ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
  File "/home/me/anaconda3/envs/py35/lib/python3.5/site-
packages/theano/gpuarray/__init__.py", line 164, in <module>
    use(config.device)
  File "/home/me/anaconda3/envs/py35/lib/python3.5/site-
packages/theano/gpuarray/__init__.py", line 151, in use
    init_dev(device)
  File "/home/me/anaconda3/envs/py35/lib/python3.5/site-
packages/theano/gpuarray/__init__.py", line 60, in init_dev
    sched=config.gpuarray.sched)
  File "pygpu/gpuarray.pyx", line 614, in pygpu.gpuarray.init 
(pygpu/gpuarray.c:9419)
  File "pygpu/gpuarray.pyx", line 566, in pygpu.gpuarray.pygpu_init 
(pygpu/gpuarray.c:9110)
  File "pygpu/gpuarray.pyx", line 1021, in 
    pygpu.gpuarray.GpuContext.__cinit__ (pygpu/gpuarray.c:13472)
pygpu.gpuarray.GpuArrayException: Error loading library: -1

我需要使用 nvidia-381 驱动程序,因为我的 GPU 是 1080 ti 并且与 nvidia-375 不兼容。我不确定这是否重要,但安装 nvcc 会覆盖 381,如果我在设置 nvcc 后重新安装 381 会导致一些错误,所以我不能使用 nvcc

我可以毫无错误地导入pygpu,但如果我运行pygpu.test(),我会收到以下错误,并且我不知道如何在没有nvcc 的情况下指定DEVICE 变量。

======================================================================
ERROR: Failure: RuntimeError (No test device specified.  Specify one using the DEVICE or GPUARRAY_TEST_DEVICE environment variables.)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/me/anaconda3/envs/py35/lib/python3.5/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/me/anaconda3/envs/py35/lib/python3.5/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/me/anaconda3/envs/py35/lib/python3.5/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/me/anaconda3/envs/py35/lib/python3.5/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/me/anaconda3/envs/py35/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/home/me/anaconda3/envs/py35/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/me/.local/lib/python3.5/site-packages/pygpu-0.6.2-py3.5-linux-x86_64.egg/pygpu/tests/test_tools.py", line 5, in <module>
    from .support import (guard_devsup, rand, check_flags, check_meta, check_all,
  File "/home/me/.local/lib/python3.5/site-packages/pygpu-0.6.2-py3.5-linux-x86_64.egg/pygpu/tests/support.py", line 32, in <module>
    context = gpuarray.init(get_env_dev())
  File "/home/me/.local/lib/python3.5/site-packages/pygpu-0.6.2-py3.5-linux-x86_64.egg/pygpu/tests/support.py", line 29, in get_env_dev
    raise RuntimeError("No test device specified.  Specify one using the DEVICE or GPUARRAY_TEST_DEVICE environment variables.")
RuntimeError: No test device specified.  Specify one using the DEVICE or GPUARRAY_TEST_DEVICE environment variables.

----------------------------------------------------------------------
Ran 7 tests in 0.003s

FAILED (errors=7)
<nose.result.TextTestResult run=7 errors=7 failures=0>

【问题讨论】:

  • 出现这种情况,可能是因为pygpu找不到合适的cuda版本。我相信 0.6.2 到 0.6.4 的 pygpu 版本适用于 Cuda 7.5,而 0.6.8 以上的版本适用于 Cuda 8.0

标签: gpu theano


【解决方案1】:

警告:这完全有可能是错误的,而您的问题的真正原因实际上是 - 正如您所怀疑的 - 您的 gpu 驱动程序。


我在 Windows 10 上使用 gpuarray 时遇到了同样的问题。 最后我解决了:

  1. 完全卸载python
  2. 安装 cuda 8.0(使用 cudnn 5.1)
  3. 安装 anaconda
  4. 通过 anaconda 安装 theano:

    conda install theano pygpu 
    

当您使用 linux 时:此错误消息基本上意味着 它不起作用,不要问我为什么并且如果您的设置有问题(例如,用于编译python和theano,或者cuda版本不兼容)

我建议更新到 cuda 8.0 并通过 anaconda 重新安装您的 python 环境(以防万一)

附带说明:我从文档中测试了您的示例脚本,至少这是有效的......


Windows 用户注意事项:切勿尝试将 Anaconda 安装在路径中有空格的位置...一切看起来都很好...直到 theano 开始无法查找和编译内容。


关于pygpu.test()的注意事项:

通常你只需设置环境变量:

windows: set DEVICE=cuda
linux: export DEVICE=cuda

但是如果无法加载库,测试习惯说您没有指定设备...

【讨论】:

  • 这确实与我的驱动程序有关。 libcuda.so.1nvidia-381 不存在,但安装 nvidia-378 为我提供了文件并与我的 GPU 保持兼容。不过,感谢您抽出宝贵的时间来写这篇文章!
  • 我就让它在那里。 pygpu.gpuarray.GpuArrayException: Error loading library: -1 的谷歌搜索结果并不多,也许有人在寻找解决方案时碰巧找到了这篇文章。
  • 对我来说很有意义。很可能它解决了某人的问题。
  • 刚刚 ping 了谷歌爬虫:google.de/… 第 4 个条目,我觉得不错(总共 5 个中的第 4 个)
  • @FabianN.:我也遇到过这样的问题,即使我重新安装了 anaconda 和 theano 并将 cuda 更新到 8.0(你可以在这里看到我的帖子:stackoverflow.com/questions/44346349/…)。没有配置使用gpu的.theanorc文件,theano可以成功导入。安装 theano 之后,你有没有做过其他的事情,比如安装其他包?您能否更具体地了解您的 .theanorc 文件和一些相关配置?谢谢!!
猜你喜欢
  • 2017-06-28
  • 2020-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-12
  • 1970-01-01
  • 2015-03-02
相关资源
最近更新 更多