Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

th cannot import packages #37

Closed
caseus-viridis opened this issue Oct 23, 2015 · 11 comments
Closed

th cannot import packages #37

caseus-viridis opened this issue Oct 23, 2015 · 11 comments

Comments

@caseus-viridis
Copy link

Same problem as in Issue #33

th> require 'nn'
/Users/___/torch/install/share/lua/5.1/trepl/init.lua:363: /Users/___/torch/install/share/lua/5.1/trepl/init.lua:363: loop or previous error loading module 'torch'
stack traceback:
    [C]: in function 'error'
    /Users/___/torch/install/share/lua/5.1/trepl/init.lua:363: in function 'require'
    [string "_RESULT={require 'nn'}"]:1: in main chunk
    [C]: in function 'xpcall'
    /Users/___/torch/install/share/lua/5.1/trepl/init.lua:630: in function 'repl'
    .../___/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:187: in main chunk
    [C]: at 0x01020a11b0    

luajit -l xlua gives:

luajit: error loading module 'libsys' from file '/Users/___/torch/install/lib/lua/5.1/libsys.so':
    dlopen(/Users/___/torch/install/lib/lua/5.1/libsys.so, 6): Library not loaded: libmkl_intel_lp64.dylib
  Referenced from: /Users/___/torch/install/lib/lua/5.1/libsys.so
  Reason: image not found
stack traceback:
    [C]: at 0x010a86f960
    [C]: in function 'require'
    /Users/___/torch/install/share/lua/5.1/sys/init.lua:14: in main chunk
    [C]: in function 'require'
    /Users/___/torch/install/share/lua/5.1/xlua/init.lua:37: in main chunk
    [C]: at 0x010a8702c0
    [C]: at 0x010a7f71b0

Running on MAC OSX 10.11

@soumith
Copy link
Member

soumith commented Oct 23, 2015

Library not loaded: libmkl_intel_lp64.dylib

That should help you fix the issue? Intel MKL seems to not be in your LD_LIBRARY_PATH / DYLD_LIBRARY_PATH

@caseus-viridis
Copy link
Author

Thanks soumith.
Adding Intel MKL path makes loading torch packages in luajit behaving normally.

luajit
LuaJIT 2.1.0-alpha -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/

 _____              _     
|_   _|            | |    
  | | ___  _ __ ___| |__  
  | |/ _ \| '__/ __| '_ \ 
  | | (_) | | | (__| | | |
  \_/\___/|_|  \___|_| |_|

JIT: ON SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
th> require 'nn'
th> 

But the same problem persists when attempting to load packages in trepl.

th

  ______             __   |  Torch7                                         
 /_  __/__  ________/ /   |  Scientific computing for Lua. 
  / / / _ \/ __/ __/ _ \  |  Type ? for help                                
 /_/  \___/_/  \__/_//_/  |  https://github.com/torch         
                          |  http://torch.ch                  

th> 
th> 
th> require 'nn'
/Users/___/torch/install/share/lua/5.1/trepl/init.lua:363: /Users/___/torch/install/share/lua/5.1/trepl/init.lua:363: loop or previous error loading module 'torch'
stack traceback:
    [C]: in function 'error'
    /Users/___/torch/install/share/lua/5.1/trepl/init.lua:363: in function 'require'
    [string "_RESULT={require 'nn'}"]:1: in main chunk
    [C]: in function 'xpcall'
    /Users/___/torch/install/share/lua/5.1/trepl/init.lua:630: in function 'repl'
    .../___/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:187: in main chunk
    [C]: at 0x01065501b0

Ideas?

@soumith
Copy link
Member

soumith commented Oct 23, 2015

@caseus-viridis that is very strange. How about in luajit, you do:
require('trepl')()

That will activate trepl in luajit

@caseus-viridis
Copy link
Author

Invoking trepl in luajit works fine. Using it as a workaround for now.
Would be nice to solve the prob tho. Thanks @soumith

@caseus-viridis
Copy link
Author

One more test: invoking trepl in luajit works fine only after MKL path was manually added to LD_LIBRARY_PATH, DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH.
Another test: without adding MKL path manually, and after a fresh install, I had the following:

luajit -l torch
luajit: /Users/___/torch/install/share/lua/5.1/torch/init.lua:14: cannot load '/Users/___/torch/install/lib/lua/5.1/libtorch.so'
stack traceback:
    [C]: in function 'require'
    /Users/___/torch/install/share/lua/5.1/torch/init.lua:14: in main chunk
    [C]: at 0x010ea5e2c0
    [C]: at 0x010e9e52e0

and

luajit
LuaJIT 2.1.0-alpha -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/

 _____              _     
|_   _|            | |    
  | | ___  _ __ ___| |__  
  | |/ _ \| '__/ __| '_ \ 
  | | (_) | | | (__| | | |
  \_/\___/|_|  \___|_| |_|

JIT: ON SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
th> require 'torch'
/Users/___/torch/install/share/lua/5.1/trepl/init.lua:363: loop or previous error loading module 'torch'
stack traceback:
    [C]: in function 'error'
    /Users/___/torch/install/share/lua/5.1/trepl/init.lua:363: in function 'require'
    [string "_RESULT={require 'torch'}"]:1: in main chunk
    [C]: in function 'xpcall'
    /Users/___/torch/install/share/lua/5.1/trepl/init.lua:630: in function </Users/___/torch/install/share/lua/5.1/trepl/init.lua:539>
    stdin:1: in main chunk
    [C]: at 0x010fc362e0

Hope this helps pinpoint the problem.

@gcr
Copy link

gcr commented Oct 26, 2015

I'm affected by this too. Digging deeper...

@caseus-viridis , do you use Anaconda? If so, do you have gcc installed into your Conda environment?

On my system, libmkl_intel_lp64.dylib only exists in the Anaconda library folder. I note that install.sh has some special logic for removing Anaconda from the build path... but I also note that whenever luarocks installs a package, it builds with ~/miniconda/bin/cc, which always generates libraries that depend on libmkl_intel_lp64.dylib.

@caseus-viridis
Copy link
Author

I don't use conda. I use enthought.

@gcr
Copy link

gcr commented Oct 26, 2015

Hm. Does enthought install mkl? Where is the mkl library on your machine?

As a workaround, deleting ./pkg/torch/lib/TH/cmake/FindMKL.cmake and rebuilding torch from scratch with ./clean.sh; ./install.sh completely fixes the issue. (What cmake can't find won't hurt it, right?)

But not sure why the library fails to load. Are there any people who use torch with MKL without any issues?

@caseus-viridis
Copy link
Author

Yes @gcr , MKL is with my version of enthought (v2.7.9), located /Library/Frameworks/EPD64.framework/Versions/7.2/lib on my mac.
Linking to it manually after torch install now as a workaround.

@caseus-viridis
Copy link
Author

@gcr , I verified your workaround on my mac with enthought MKL.

@soumith soumith closed this as completed Nov 3, 2015
@admercs
Copy link

admercs commented Jun 8, 2016

This solution of @gcr worked for me as well. Anaconda really messes with things on OS X.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants