0

I'm new to lua and recently learning DL with Torch. I have installed torch just following instructions: http://torch.ch/docs/getting-started.html#_ and added some packages using luarocks install. Then I wrote a test file:

require 'torch'
require 'nn'

--[[do something]]

when running with lua test.lua (Ubuntu 14.04), it errs as followed:

error loading module 'libpaths' from file '/home/user1/torch/install/lib/lua/5.1/libpaths.so': /home/user1/torch/install/lib/lua/5.1/libpaths.so: undefined symbol: luaL_register

It seems something wrong with path settings or so. However, when I run test with command th, it works fine. I searched and examined these answers: Error loading module (Lua) Torch7 Lua, error loading module 'libpaths' (Linux) not fully answered my question though.
So I wonder where exactly the error comes from, and how to fix it. Even though I can use torch with th.

ADD: I find that the reason maybe API luaL_register is not supported in ver 5.2 which is what I am using, while th calls a lua shell in ver 5.1? So does this mean I can only use th to run my files?

4
  • Before installing torch, did you have Lua already installed on your machine? What do you get if you do: which lua and which luajit? Commented Apr 13, 2016 at 7:25
  • Yes, I installed lua before torch. And it shows /usr/bin/lua and /home/user1/torch/install/bin/luajit, so can I run lua with specific version appointed? Commented Apr 13, 2016 at 7:41
  • You clearly need to use either luajit or th and not your system-wide lua install. Otherwise it conflicts with Torch install (rocks are not installed at the right place, plus your Lua version is > 5.1 hence the troubles with parts of Torch code that have been compiled for lower LUA_VERSION_NUM, etc). Commented Apr 13, 2016 at 7:45
  • It means that you buld libpaths with include files from different Lua version than you run. Commented Apr 13, 2016 at 10:49

1 Answer 1

3

You are likely using your system Lua (probably version 5.2), but Torch requires LuaJIT it comes with. Run your script as luajit test.lua (it's probably in /home/user1/torch/install/bin/luajit).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.