OpenNMT Forum

Training success but unable to translate

opennmt-lua

(Natsu O) #1

Recently, I have configured the OpenMNT (lua) in my system Ubuntu 16.04 LTS (Desktop PC without GPU):

sudo apt-get install libreadline-dev
sudo apt-get install luarocks

sudo chown -R pcName: usr/local/lib/luarocks
pcName@pcName-COMP:/$ sudo chmod -R u+w usr/local/lib/luarocks

git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch;
bash install-deps;

==> Found GCC 5, installing GCC 4.9.
[sudo] password for pcName:

To install the library, you can run “make PREFIX=/path/to/your/installation install”.
[sudo] password for pcName:

pcName@pcName-COMP:~/torch$ ./install.sh
Prefix set to /home/pcName/torch/install
Installing Lua version: LUAJIT21

Do you want to automatically prepend the Torch install location
to PATH and LD_LIBRARY_PATH in your /home/pcName/.bashrc? (yes/no)
[yes] >>>
yes

source ~/.bashrc
sudo chown -R $(whoami) ~/.cache

git config --global url.“https://”.insteadOf git://

luarocks install tds
luarocks install bit32

git clone https://github.com/OpenNMT/OpenNMT
cd OpenNMT

After the installation, I have followed the stpes as instructed in the website and was able to pre-process and train it successfully.

th preprocess.lua -train_src data/src-train.txt -train_tgt data/tgt-train.txt -valid_src data/src-val.txt -valid_tgt data/tgt-val.txt -save_data data/demo
th train.lua -data data/demo-train.t7 -save_model model

BUT, it is giving issue while I am trying to translate it:

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

Error:

~/OpenNMT$ th translate.lua -model data/demo-train.t7 -src data/src-test.txt -output pred.txt -gpuid 0
[03/09/19 03:50:55 INFO] Loading 'data/demo-train.t7'...	
/home/pcName/torch/install/bin/luajit: ./onmt/translate/Translator.lua:202: attempt to index field 'options' (a nil value)
stack traceback:
	./onmt/translate/Translator.lua:202: in function '__init'
	/home/pcName/torch/install/share/lua/5.1/torch/init.lua:91: in function 'new'
	translate.lua:80: in function 'main'
	translate.lua:365: in main chunk
	[C]: in function 'dofile'
	...pcName/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
	[C]: at 0x00405d50

I have checked the forum but couldn’t find the relevant solution.

Edit: same issue was raised here: …t/translation-gives-error/1041

I checked ‘demo-train.t7’ file, and its there and not empty.


(Guillaume Klein) #2

Can you restart the training to produce another checkpoint and check if the error still occurs?