hughperkins / clnn

OpenCL backend for Torch nn neural networks library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CLNN master/thnn4 build error

adrien806 opened this issue · comments

Hi Hugh,
I believe there is a link error in the current thnn4 / master branch.
The function GET_BLOCKS is in common.h, which has been compiled correctly

[ 25%] Building CXX object CMakeFiles/clnn.dir/common.cpp.o
[100%] Linking CXX shared module libTHCLNN.so
Undefined symbols for architecture x86_64:
"GET_BLOCKS(THClState*, int)", referenced from:
_THNN_ClSpatialAveragePooling_updateOutput in SpatialAveragePooling.cpp.o

Thanks in advance for the help.

It builds ok for me. Can you do the following and check the problem does/doesnt still occur:

luarocks install torch
luarocks install nn
luarocks install cltorch
luarocks install clnn

Ah, seems travis, on Mac OS X, has the same issue, https://travis-ci.org/hughperkins/clnn/builds/107116666 Hmmm.

Can you confirm what platform you are on please?

EDIT: post-typo

I am on Mac OS 10.11.3

To confirm, all the master branches are now in sync - so we can disregard the "bleeding edge" instructions?

I ran

luarocks install torch
luarocks install nn
luarocks install cltorch
luarocks install clnn

And clnn did not build.

sorry, I meant luarocks install torch, corrected this above.

Corrected as well.

I am on Mac OS 10.11.3

yes, I think it's a problem specific to Mac OS X. Luckily, I do have Mac OS X build on travis, so I can try .. stuff... see if I can fix it. If you happen to have any ideas in the meantime please let me know. It problably involves a combination of one or both of the following mac-specific things:

  • symbols in one dll arent available to later dlls by default, without some work
    • and non-flat namespace doesnt help here
  • undefined symbols in a dll cause an error at linktime, whereas in linux, I think they are silently ignored, unless you try calling them

Seems the symbols really are needed, so it's probably to do with the first issue.

I've moved common.cpp/.h into lib/THCLNN directory/dylib. That hopefully eliminates the build errors with GET_BLOCKS and GET_CL_NUM_THREADS. Then, (if those are fixed), "just" need to fix the issues with the TemplatedKernel symbols (which are in libEasylCL, I think)

Indeed, the missing symbols are now from the classes TemplatedKernel and EasyCL.

So, basically, on linux, by doing objdump somelib.so | grep NEEDED, starting with build/lib/THCLNN/lib/libTHCLNN.so, we have the following chain of dependencies:

  • libTHCLNN.so => depends directly on libTHCl.so
  • libTHCl.so => depends directly on libEasyCL.so

Unfortunately, libTHCLNN.so needs a couple of symbols from libEasyCL.so, and, on Mac, these are not available to libTHCLNN.so by default. Needs some magic linking options I think.

Edit: Update: the GET_BLOCKS and GET_CL_NUM_THREADS errors have now disappeared https://travis-ci.org/hughperkins/clnn/builds/107120893 Editedit: ah you saw that too :-)

Ah, the easiest way to try it I think is something like:

git clone https://github.com/hughperkins/clnn.git
cd clnn
luarocks make rocks/clnn-scm-1.rockspec

Once you've done this once, then you can run cmake directly:

cd build
# if you want, you can run ccmake from here, like: ccmake ..
# otherwise, directly:
make

Thanks, as far as I know the directory where shared libraries are looked up is different on Mac.

But it could just be that the install/lib/ torch folder does not have a libEasyCL.so, but a libEasyCL.dylib (http://stackoverflow.com/questions/2339679/what-are-the-differences-between-so-and-dylib-on-osx)

Yeah, when I say .so on mac, that will sometimes be .dylib, sometimes .so, depending on the linker options supplied.

I've added EasyCL as a direct dependency of THCLNN, maybe that will help. But I should go to bed now-ish really, so I will check in the morning. 19ab3b5

Built ok too, thanks for the help.

Cool :-)