0
votes

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?

1
Before installing torch, did you have Lua already installed on your machine? What do you get if you do: which lua and which luajit? - deltheil
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? - Varg Nord
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). - deltheil
It means that you buld libpaths with include files from different Lua version than you run. - moteus

1 Answers

3
votes

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).