使用 lua 时加载模块时出错

Error loading module when using lua

我是 lua 的新手,最近正在使用 Torch 学习深度学习。 我已经按照说明安装了 torch:http://torch.ch/docs/getting-started.html#_ 并使用 luarocks install 添加了一些包。然后我写了一个测试文件:

require 'torch'
require 'nn'

--[[do something]]

当运行 lua test.lua (Ubuntu 14.04)时,报错如下:

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

路径设置好像有问题。但是,当我 运行 使用命令 th 进行测试时,它工作正常。 我搜索并检查了这些答案:Error loading module (Lua) Torch7 Lua, error loading module 'libpaths' (Linux) 虽然没有完全回答我的问题。
所以我想知道错误到底是从哪里来的,以及如何解决它。即使我可以将手电筒与 th.

一起使用

添加: 我发现我正在使用的版本 5.2 不支持 API luaL_register 的原因,而 th 在版本 5.1 中调用 lua shell ?那么这是否意味着我只能使用 th 来 运行 我的文件?

您可能正在使用您的系统 Lua(可能是 5.2 版),但 Torch 需要 Lua它附带的 JIT。 运行 您的脚本为 luajit test.lua(可能在 /home/user1/torch/install/bin/luajit 中)。