LUA - 尝试索引全局变量'jit'(一个空值)

我在我的机器上运行 ubuntu 16.04。 并且尝试运行下面提供的代码,它总是返回“尝试索引全局变量'jit'(一个空值)”:

#!/usr/bin/env th

require 'torch'
require 'optim'

require 'paths'

require 'xlua'
require 'csvigo'

require 'nn'
require 'dpnn'

local opts = paths.dofile('opts.lua')

opt = opts.parse(arg)
print(opt)

torch.setdefaulttensortype('torch.FloatTensor')

if opt.cuda then
   require 'cutorch'
   require 'cunn'
   cutorch.setDevice(opt.device)
end

opt.manualSeed = 2
torch.manualSeed(opt.manualSeed)

paths.dofile('dataset.lua')
paths.dofile('batch-represent.lua')

model = torch.load(opt.model)
model:evaluate()
if opt.cuda then
   model:cuda()
end

repsCSV = csvigo.File(paths.concat(opt.outDir, "reps.csv"), 'w')
labelsCSV = csvigo.File(paths.concat(opt.outDir, "labels.csv"), 'w')

batchRepresent()

repsCSV:close()
labelsCSV:close()

我真的不明白为什么会出现这个错误,以及我该如何解决它。 我做错了什么吗?

完整输出

/home/yalishanda/torch/install/bin/lua: /home/yalishanda/openface/batch-represent/dataset.lua:130:尝试索引全局变量'jit'(一个空值)
stack traceback:
    /home/yalishanda/openface/batch-represent/dataset.lua:130:在函数'__init'中
    /home/yalishanda/torch/install/share/lua/5.2/torch/init.lua:91:在函数</home/yalishanda/torch/install/share/lua/5.2/torch/init.lua:87>中
    [C]:在函数'dataLoader'中
    .../yalishanda/openface/batch-represent/batch-represent.lua:19:在函数'batchRepresent'中
    ../batch-represent/main.lua:42:在主块中
    [C]:在函数'dofile'中
    ...anda/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150:在主块中
    [C]:在?
^CTraceback (most recent call last):
  File "./myScript.py", line 47, in <module>
    ret, frameRGB = video_capture.read()
点赞
用户1442917
用户1442917

你似乎在运行普通的 Lua 解释器,但是你需要运行 LuaJIT(它提供了脚本中使用的模块期望访问的“jit”表)。由于你正在使用 Torch,确保使用包含在 Torch 中的 LuaJIT 解释器,问题应该就会消失。

2017-08-03 04:03:31