导入 Torch 包时出现错误

我刚刚按照说明 的步骤安装了 Torch7。然而,我无法通过命令行解释器导入任何包:

kamransiquisMBP:~ khsiddiqui$ th

  ______             __   |  Torch7
 /_  __/__  ________/ /   |  用于 Lua 的科学计算
  / / / _ \/ __/ __/ _ \  |  输入 ? 获取帮助
 /_/  \___/_/  \__/_//_/  |  https://github.com/torch
                          |  http://torch.ch

    th> require "nn"
    ...rs/khsiddiqui/torch/install/share/lua/5.1/trepl/init.lua:384:
    ...rs/khsiddiqui/orch/install/share/lua/5.1/trepl/init.lua:384:
    循环或先前错误加载模块'torch'
    堆栈回溯:
        [C]: in function 'error
        ...rs/khsiddiqui/torch/install/share/lua/5.1/trepl/init.lua:384:
        in function 'require' [string "_RESULT={require "nn"}"]:1: in main chunk
        [C]: in function 'xpcall'
        ...rs/khsiddiqui/torch/install/share/lua/5.1/trepl/init.lua:651:
        in function 'real'...iqui/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199:
        in main chunk
        [C]: at 0x010fc1cd00
    th> 1 + 1
    2

除解释器以外,在命令行状态下,我运行了命令 luarocks install nn,但上述相同的错误仍然存在。

希望能够快速解决 Torch7 的安装问题!


嗨,@deltheil ...

kamransiquisMBP:~ khsiddiqui$ luajit -ltorch
luajit: /usr/local/share/lua/5.1/torch/init.lua:11: 无法加载
 '/usr/local/lib/lua/5.1/libtorch.so'
堆栈回溯:
    [C]: in function 'require'
    /usr/local/share/lua/5.1/torch/init.lua:11: in main chunk
    [C]: at 0x010a587dd0
    [C]: at 0x010a50bd00

在运行了 luajit 之后,运行以下代码...

th> ok, err = pcall(require, 'libtorch')
th> print(ok, err)
false   error loading module 'lib torch' from file
'/usr/local/lib/lua/5.1/libtorch.so':
dlopen(/usr/local/lib/lua/5.1/libtorch.so,
 6): Library not loaded: libmkl_intel_lp64.dylib
  Referenced from: /Users/khsiddiqui/torch/install/lib/libTH.dylib
  Reason: image not found
点赞
用户4611375
用户4611375

根据此页面上的指示,我在Mac OSX上完成以下操作:

  1. 定位并删除文件./pkg/torch/lib/TH/cmake/FindMKL.cmake...
  2. 运行./clean.sh; ./install.sh进行干净的安装...

之后Torch按预期运行:-)。 我正在进行机器学习!

2016-04-10 15:41:47