如何在屏幕会话中使用 theano?

How to use theano within screen session?

我在我第一次通过 ssh 进入的远程服务器上使用 theano(我在那个系统上没有 root)。这工作正常,但是,如果我启动 screen,我在尝试导入 theano 时遇到错误。

不使用时的行为 screen:

>>> import theano
Using gpu device 0: GeForce GTX TITAN X (CNMeM is disabled, CuDNN 4007)

使用 screen 时的行为:

>>> import theano
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: libcublas.so.7.5: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/2012/enewel3/.local/lib/python2.7/site-packages/theano/__init__.py", line 103, in <module>
    import theano.sandbox.cuda
  File "/home/2012/enewel3/.local/lib/python2.7/site-packages/theano/sandbox/cuda/__init__.py", line 697, in <module>
    use(device=config.device, force=config.force_device, test_driver=False)
  File "/home/2012/enewel3/.local/lib/python2.7/site-packages/theano/sandbox/cuda/__init__.py", line 496, in use
    device, cuda_initialization_error_message))
EnvironmentError: You forced the use of gpu device gpu, but CUDA initialization failed with error:
cuda unavailable

我应该如何在屏幕会话中使用 theano?

问题是因为虽然screen继承了大部分环境变量,但它添加、删除和更改了其中的一些。在我的例子中,它正在改变 LD_LIBRARY_PATH.

的值

进入屏幕后,手动将环境变量设置为正确的值解决了问题。对我来说,它看起来像这样:

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/pkgs/gurobi502/linux64/lib

将该行添加到我的 .bashrc 可确保屏幕始终获得正确的值。请注意,将它添加到 .bash_profile 是行不通的,因为 .bash_profile 在登录时只有 运行,而 .bashrc 对于每个新的 shell 都是 运行 .