karpathy / char-rnn

Multi-layer Recurrent Neural Networks (LSTM, GRU, RNN) for character-level language models in Torch
11.57k stars 2.58k forks source link

Error: table index is nil #83

Open vinceallenvince opened 9 years ago

vinceallenvince commented 9 years ago

I can train and sample files just fine on OS X. However, on a machine running Ubuntu 14.04, when trying to sample (ie. th sample.lua...), I get the following error. I've tried installing Torch w both luajit and plain lua (ie. TORCH_LUA_VERSION=LUA51 ./install.sh). But I still get the error. Any ideas? Thx.

/root/torch/install/bin/lua: /root/torch/install/share/lua/5.1/torch/File.lua:283: table index is nil stack traceback: /root/torch/install/share/lua/5.1/torch/File.lua:283: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:268: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:268: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:268: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' ... /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:268: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:282: in function 'readObject' /root/torch/install/share/lua/5.1/torch/File.lua:305: in function 'load' sample.lua:67: in main chunk C: in function 'dofile' .../torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:131: in main chunk

hughperkins commented 9 years ago

Not saying it will fix the problem, but seems like you are using a fairly old version of char-rnn?

EricZeiberg commented 9 years ago

How can you tell?

hughperkins commented 9 years ago

becuaase line 67 of karpathy/master doesnt call File:load :-P

vinceallenvince commented 9 years ago

Thx, pulled the latest but still get the error on another line. sample.lua:86: in main chunk

hughperkins commented 9 years ago

Ok. Are you sampling from a cv file created using the same version of char-rnn, or a different version?

vinceallenvince commented 9 years ago

I'm sampling from a file created using an earlier version. I'll train a file with the new version and sample and see what happens.

vinceallenvince commented 9 years ago

Wow, ok.. I trained until I got one checkpoint file and sampled it and it worked! Thx.

EricZeiberg commented 9 years ago

If the issue has been fixed, please close this.

vinceallenvince commented 9 years ago

One more question.. I notice if I'm on my Ubuntu machine and try to sample checkpoints trained on OS X, I get the error. Is that expected? In other words, i should only try to sample from checkpoints trained on the same environment? Thx.

hughperkins commented 9 years ago

Are you using the same versoin on each?

vinceallenvince commented 9 years ago

Yes, just tested training on OS X and sampling a checkpoint from the training on Ubuntu. Same error.

hughperkins commented 9 years ago

Interesting. I suppose it is to do with endian-ness plausibly. Does your Mac have an intel x86 processor, or some kind of 68000 type non-Intel processor?

soumith commented 9 years ago

if you want to have cross-platform checkpoints, torch.save in ascii mode. torch.save('checkpoint.t7', net, 'ascii')

soumith commented 9 years ago

if you do 64-bit OSX and 64-bit Ubuntu, both on x64 processors. they should be fully compatible in terms of serialization. they only start getting weird when the processor endianness changes:

https://github.com/torch/torch7/issues/5

EricZeiberg commented 9 years ago

Also, be wary of saving the checkpoint under the same name every time, iirc it will override the previous one. On Aug 15, 2015 10:21 PM, "Soumith Chintala" notifications@github.com wrote:

if you do 64-bit OSX and 64-bit Ubuntu, both on x64 processors. they should be fully compatible in terms of serialization. they only start getting weird when the processor endianness changes:

torch/torch7#5 https://github.com/torch/torch7/issues/5

— Reply to this email directly or view it on GitHub https://github.com/karpathy/char-rnn/issues/83#issuecomment-131477159.