hughperkins / clnn

OpenCL backend for Torch nn neural networks library
BSD 2-Clause "Simplified" License
125 stars 16 forks source link

On Mac: "THCLNN.lua:11: bad argument #1 to 'load'" #24

Closed hughperkins closed 8 years ago

hughperkins commented 8 years ago

see https://github.com/hughperkins/clnn/issues/22#issuecomment-168491731 :

Per @salicylic :

After updating to most recent clnn version, build goes through, but now require 'clnn' fails:

th> require 'clnn'
libthclnn_searchpath    nil
...ta/Users/jan/torch/install/share/lua/5.1/clnn/THCLNN.lua:11: bad argument #1 to 'load' (string expected, got nil)
stack traceback:
    [C]: in function 'load'
    ...ta/Users/jan/torch/install/share/lua/5.1/clnn/THCLNN.lua:11: in main chunk
    [C]: in function 'require'
    ...Data/Users/jan/torch/install/share/lua/5.1/clnn/init.lua:5: in main chunk
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: at 0x010486aba0
hughperkins commented 8 years ago

@salicylic , just to confirm ,this is for Mac, right?

data-ux commented 8 years ago

Yes, Mac OS 10.11.2.

hughperkins commented 8 years ago

k, thanks!

hughperkins commented 8 years ago

Interesting: seems like everything in ~/torch/install/lib is a .dylib, whereas everything in ~/torch/install/lib/lua/5.1 is an .so, on Mac, https://travis-ci.org/hughperkins/clnn/builds/99959543#L1563-L1577

$ ls ~/torch/install/lib
libEasyCL.dylib     libclBLAS.dylib     libthreadsmain.so
libTH.dylib     libclew.1.0.0.dylib lua
libTHCl.dylib       libclew.dylib       luarocks
libclBLAS.2.4.0.dylib   libluaT.dylib
libclBLAS.2.dylib   libluajit.dylib
The command "ls ~/torch/install/lib" exited with 0.

0.01s$ ls ~/torch/install/lib/lua/5.1
base64.so   lfs.so      libimage.so libpng.so   libthreads.so
cjson.so    libTHCLNN.dylib libjpeg.so  libppm.so   libtorch.so
crypto.so   libTHNN.so  libnn.so    libsignal.so    readline.so
ffi     libclnn.so  libnnx.so   libsundown.so   treplutils.so
ffi.so      libcltorch.so   libpaths.so libsys.so

I guess somehow libTHCLNN.dylib should in fact be a .so too somehow.

hughperkins commented 8 years ago

Changed THCLNN to a .so in https://github.com/hughperkins/clnn/commit/3026b4e233835c7848e3b7edde758e4cc5eff683 but now get error about libpaths cant be found, https://travis-ci.org/hughperkins/clnn/builds/99961544#L2443-L2452 :

$ luajit -e 'require "clnn"'
luajit: /Users/travis/torch/install/share/lua/5.1/paths/init.lua:1: module 'libpaths' not found:
    no field package.preload['libpaths']
    no file './libpaths.lua'
    no file '/Users/travis/torch/install/share/luajit-2.1.0-beta1/libpaths.lua'
    no file '/usr/local/share/lua/5.1/libpaths.lua'
    no file '/usr/local/share/lua/5.1/libpaths/init.lua'
    no file '/Users/travis/torch/install/share/lua/5.1/libpaths.lua'
    no file '/Users/travis/torch/install/share/lua/5.1/libpaths/init.lua'
    no file '/Users/travis/torch/install/lib/libpaths.dylib'
    no file '/Users/travis/torch/install/lib/libpaths.dylib'

But the odd thing is that libpaths.so exists, https://travis-ci.org/hughperkins/clnn/builds/99961544#L2429-L2433 :

$ ls ~/torch/install/lib/lua/5.1
cjson.so    lfs.so      libclnn.so  libpaths.so libtorch.so
ffi     libTHCLNN.so    libcltorch.so   libsundown.so
ffi.so      libTHNN.so  libnn.so    libsys.so

... so that is a mystery. I seem to remember seeing this problem before though. I think its something to do with flat namespace, or having to load using dyload( ... , GLOBAL_TLD), but I remember it's not very easy to solve...

hughperkins commented 8 years ago

apparently can reproduce in cltorch, dont even need clnn to reproduce https://travis-ci.org/hughperkins/cltorch/builds/99968449#L2514 :

$ luajit -e 'require "cltorch"'
luajit: /Users/travis/torch/install/share/lua/5.1/paths/init.lua:1: module 'libpaths' not found:
    no field package.preload['libpaths']
    no file './libpaths.lua'
    no file '/Users/travis/torch/install/share/luajit-2.1.0-beta1/libpaths.lua'
    no file '/usr/local/share/lua/5.1/libpaths.lua'
    no file '/usr/local/share/lua/5.1/libpaths/init.lua'
    no file '/Users/travis/torch/install/share/lua/5.1/libpaths.lua'
    no file '/Users/travis/torch/install/share/lua/5.1/libpaths/init.lua'
    no file '/Users/travis/torch/install/lib/libpaths.dylib'
hughperkins commented 8 years ago

I think it's all working ok now actually :-) https://travis-ci.org/hughperkins/clnn/branches

jimwebb commented 8 years ago

Works for me now also (Mac OS 10.11.2). Thanks for the quick attention!

hughperkins commented 8 years ago

Cool! :-)