使用Theano加载库gpuarray时出错 [英] Error loading library gpuarray with Theano

查看:145
本文介绍了使用Theano加载库gpuarray时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行

我需要使用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>

解决方案

警告:完全有可能这都是错误的,而导致问题的实际原因实际上是-您怀疑-您的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开始查找和编译错误. /p>


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

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

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

该测试的习惯是,如果无法加载该库,则您未指定设备...

I am trying to run this script to test Theano's use of my GPU and get the following error:

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

I need to use the nvidia-381 driver since my GPU is a 1080 ti and is not compatible with nvidia-375. I'm not sure if that matters but installing nvcc overwrites 381 and causes some errors if I reinstall 381 after setting up nvcc so I can't use nvcc.

I can import pygpu without errors but if I run pygpu.test() I get the following error and I don't know how to specify the DEVICE variable without nvcc.

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

解决方案

Warning: its entirely possible that this is all wrong and the actual reason for your problem is in fact - as you suspect - your gpu driver.


I had the same issue with gpuarray on Windows 10. In the end I solved it by:

  1. completely uninstall python
  2. install cuda 8.0 (with cudnn 5.1)
  3. install anaconda
  4. install theano through anaconda:

    conda install theano pygpu 
    

As you are using linux: This error message basically means It didn't work, don't ask me why And is mostly shown if something with your setup is wrong (e.g. different compilers used for compiling python and theano, or incompatible cuda version)

I would recommend to update to cuda 8.0 and to reinstall your python environment over anaconda (just in case)

On a side note: I tested your example script from the docu and at least that is working....


Note for windows users: Never try to install Anaconda in a location where you have spaces in the path... Everything looks fine ... until theano starts having trouble finding and compiling things.


Note regarding the pygpu.test():

Normally you just set the environment variable:

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

BUT The test has the habit of saying you didn't specify a device if the library couldn't be loaded...

这篇关于使用Theano加载库gpuarray时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆