Unknown Torch Class... and

Hello,
So I am following the instructions from the new documentation:
http://opennmt.net/OpenNMT/quickstart/#step-3-translate
th translate.lua -model demo-model_epochX_PPL.t7 -src data/src-test.txt -output pred.txt

I’m getting the following error below. It happens regardless if I specify -gpuid on training and translating.

:~/torch/opennmt# th translate.lua -model demo-model_epoch13_804.29.t7 -src data/src-test.txt -output pred.txt -gpuid 1
[04/05/17 23:00:37 INFO] Using GPU(s): 1
[04/05/17 23:00:37 WARNING] The caching CUDA memory allocator is enabled. This allocator improves performance at the cost of a higher GPU memory usage. To optimize for memory, consider disabling it by setting the environment variable: THC_CACHING_ALLOCATOR=0
[04/05/17 23:00:37 INFO] Loading ‘demo-model_epoch13_804.29.t7’…
/root/torch/install/bin/luajit: ./onmt/translate/Translator.lua:356: bad argument #1 to ‘next’ (table expected, got nil)
stack traceback:
[C]: in function ‘next’
./onmt/translate/Translator.lua:356: in function 'translate’
translate.lua:101: in function 'main’
translate.lua:182: in main chunk
[C]: in function ‘dofile’
/root/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00406670

I have researched this error and not finding relevant posts for “bad argument #1 to ‘next’” I have found related posts but none that I find helpful.

Please advise. I simply used the last model created epoch (13). The documentation (http://opennmt.net/OpenNMT/quickstart/#step-3-translate) doesn’t exactly spell it out, but I think I am supposed to use the last epoch or at least the one with the lowest perplexity?

th translate.lua -model demo-model_epochX_PPL.t7 -src data/src-test.txt -output pred.txt

I am using the demo data that comes with the git repo. I just would like to get my first NMT model created.

Thank you,
Steve

Hi Steve, sorry there was a bug caused by a recent commit. I fixed it (@7628c34) on the master you can update or switch to last stable version here: https://github.com/OpenNMT/OpenNMT/releases.

Hi Jean!
Thank you! I’m good to go. I trained my first Neural MT model! :champagne::metal:

I seem to have a similar problem: preprocessing and training work fine. If I try it on the quickstart commands, I get:

[vincent@knox /home/local/opennmt/OpenNMT]$ th translate.lua -model model_epoch13_809.30.t7 -src data/src-test.txt -output pred.txt
[08/24/17 11:42:59 INFO] Loading ‘model_epoch13_809.30.t7’…
/home/pricie/vincent/torch/install/bin/luajit: …ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:343: unknown Torch class <torch.CudaTensor>
stack traceback:
[C]: in function ‘error’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:343: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:369: in function ‘readObject’
…pricie/vincent/torch/install/share/lua/5.1/nn/Module.lua:192: in function ‘read’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:351: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:369: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:369: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:353: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:368: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:369: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:369: in function ‘readObject’

…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:369: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:369: in function ‘readObject’
…ricie/vincent/torch/install/share/lua/5.1/torch/File.lua:409: in function ‘load’
./onmt/translate/Translator.lua:119: in function ‘__init’
…ricie/vincent/torch/install/share/lua/5.1/torch/init.lua:91: in function 'new’
translate.lua:60: in function 'main’
translate.lua:208: in main chunk
[C]: in function ‘dofile’
…cent/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x004064f0

I also don’t seem to get a model_final.t7 file

Can you help me? tx.

You are loading a GPU model, so you need to set a GPU device during translation (e.g. -gpuid 1).

1 Like

Thanks for the quick reply – now it works (and I beat my best Moses BLEU score :wink: on the same dataset)