在 Theano 中使用屏幕会话 - 竞争条件

Using screen session with Theano - race conditions

在屏幕会话中训练在 Keras 中实现的神经网络时,我似乎 运行 陷入了与 Theano 的竞争条件。

我进行如下处理。我通过 SSH 连接到我正在使用的计算集群(我是 不是 的根用户)。

那我运行:

screen -S model1

然后,一旦我进入这个屏幕会话,我就 运行 Python 脚本来训练我的模型。我分离屏幕 (Ctrl+A+D),当我执行屏幕 -r 时,一切都很好。但是,如果我在 运行 screen -r 之前退出我的 ssh 会话,并且在重新登录时 运行 screen -r,那么我会收到以下错误:

compilelock.py", line 91, in get_lock
  File "~/.local/lib/python2.7/site-packages/theano/gof/compilelock.py", line 275, in lock
OSError: [Errno 13] Permission denied: '~/.theano/compiledir_Linux-3.11--generic-x86_64-with-Ubuntu-13.10-saucy-x86_64-2.7.5+-64/lock_dir'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "~/.local/lib/python2.7/site-packages/theano/gof/cmodule.py", line 1344, in _on_atexit
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "~/.local/lib/python2.7/site-packages/theano/gof/compilelock.py", line 54, in lock_ctx
  File "~/.local/lib/python2.7/site-packages/theano/gof/compilelock.py", line 91, in get_lock
  File "~/.local/lib/python2.7/site-packages/theano/gof/compilelock.py", line 275, in lock
OSError: [Errno 13] Permission denied: '~/.theano/compiledir_Linux-3.11--generic-x86_64-with-Ubuntu-13.10-saucy-x86_64-2.7.5+-64/lock_dir'

有谁知道为什么会这样?有趣的是,它仅在我注销并在登录后尝试 运行 screen -r 时发生。

我猜你的主目录在某种网络文件系统上(例如 AFS)。如果是这样,一旦您结束会话,文件系统安全凭证就会失效,并且该进程虽然会继续 运行 在屏幕内,但不再有权使用 Theano 缓存目录中的文件 ~/.theano.如果这个猜测是正确的,那么问题就不是竞争条件。

如果问题与 AFS 凭据过期有关,那么解决方案是通过 kinit 命令使用凭据缓存(请参阅 http://web.mit.edu/kerberos/krb5-1.12/doc/user/user_commands/kinit.html 中的 -c 选项)。