Search code examples
bashluatorch

Error importing packages into Torch


I just installed Torch7 as per the instructions. However, I am unable to port any packages via the command-line interpreter:

kamransiquisMBP:~ khsiddiqui$ th

  ______             __   |  Torch7                                         
 /_  __/__  ________/ /   |  Scientific computing for Lua. 
  / / / _ \/ __/ __/ _ \  |  Type ? for help                                
 /_/  \___/_/  \__/_//_/  |  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:
    loop or previous error loading module 'torch'
    stack traceback:
        [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

Outside of the interpreter, (just from the command line) I ran the command luarocks install nn, but the same error described above persisted.

Would love to get Torch7 up and running!


Hi, @deltheil ...

kamransiquisMBP:~ khsiddiqui$ luajit -ltorch
luajit: /usr/local/share/lua/5.1/torch/init.lua:11: cannot load
 '/usr/local/lib/lua/5.1/libtorch.so'
stack traceback:
    [C]: in function 'require'
    /usr/local/share/lua/5.1/torch/init.lua:11: in main chunk
    [C]: at 0x010a587dd0
    [C]: at 0x010a50bd00

Running the following after 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

Solution

  • Thanks be to @deltheil for the assistance!

    As per the instructions on this page, what worked for me (on Mac OSX) was:

    1. Locating and removing the file ./pkg/torch/lib/TH/cmake/FindMKL.cmake ...
    2. Doing a clean install by running ./clean.sh; ./install.sh ...

    After that Torch is running as intended :-). I am machine learning as we speak!