Torch:RNN 从 GPU 内存中克隆 运行

Torch: RNN clones run out of GPU memory

Karpathy 的 char-rnn(基于 Wojciechz learning_to_execute)使用常见的 RNN hack:

当我克隆 217 次(阈值可能更低)时,我可以看到我的 5GB GPU 内存 运行,结果是:

lua opt/torch/install/share/lua/5.1/torch/File.lua:270: cuda runtime error (2) : out of memory at /mounts/Users/student/davidk/opt/torch/extra/cutorch/lib/THC/THCStorage.cu:44

问题出在 clone_many_times() 函数(上面链接)。克隆体似乎指向原型中相同的物理参数存储,但由于某种原因它仍然爆炸。

有没有人遇到过这个and/or知道如何训练很长的序列?

(这里问了同样的问题:https://github.com/karpathy/char-rnn/issues/108

为了 运行 这个模型,我不得不增加 GPU 的内存容量。使用 Sun 的 Grid Engine,使用 -l h_vmem=8G 获得 8 GB

否则,您可以尝试torch-rnn。它使用 Adam 进行优化并硬编码 RNN/LSTM forward/backward 传递以提高 space/time 效率。这也避免了克隆模型的麻烦。