hughperkins / clnn

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

Allow MSECriterion with variable batch size #20

Closed petrjanda closed 8 years ago

petrjanda commented 8 years ago

Fixes https://github.com/hughperkins/clnn/issues/19

WIP

petrjanda commented 8 years ago

For the record I have 3 unit tests failing when i run full test suite.

The error message is /Users/petr/torch/install/share/lua/5.1/nn/Abs.lua:8: attempt to index field 'THNN' (a nil value) (although these were failing even before I've started).

hughperkins commented 8 years ago

Awesome! Test looks good. Fix looks good. For commit_generated.h, this is a generated file, at build time. It should be in .gitignore, but I hadnt added it. Can you pull down the latest changes, and remove it from the commit?

For the record I have 3 unit tests failing when i run full test suite.

Interesting. I should look at fixing that. Seems to plausibly be connected with https://github.com/torch/nn/commit/ad1efeed343a6f82593a15e78ea7e7bd6ceb041c , which I need to figure out how and why. But it is in any case not related to your pull request.

(accidentally posted extraneous comment into this thread, removed it)

hughperkins commented 8 years ago

(Note: Abs issue should be solved now; if you pull down latest version of clnn, and rebuild, should no longer be present)

petrjanda commented 8 years ago

Can you pull down the latest changes, and remove it from the commit?

Done

if you pull down latest version of clnn, and rebuild, should no longer be present

Done that, getting:

luarocks make rocks/clnn-scm-1.rockspec && luajit -l clnn -e 'clnn.test()'
cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH="/Users/petr/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1" && make -j$(getconf _NPROCESSORS_ONLN) install

-- Found Torch7 in /Users/petr/torch/install
Torch_INSTALL_LIB /Users/petr/torch/install/lib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/petr/Research/deeplearning/clnn/build
[  5%] Linking CXX shared library libTHCLNN.dylib
[ 50%] Built target clnn
[ 95%] Built target clnn_static
ld: library not found for -lTHC
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/THCLNN/libTHCLNN.dylib] Error 1
make[1]: *** [lib/THCLNN/CMakeFiles/THCLNN.dir/all] Error 2
make: *** [all] Error 2

Error: Build error: Failed building.

Its long time since I was writing C so can't tell if its the repo or my machine missing the library.

hughperkins commented 8 years ago

Hmmm... I'm guessing this is on a Mac right.... I think I have a way of trying builds on a Mac, but it might take me a while to figure out. You might want to reset your branch to just before the merge perhaps.

petrjanda commented 8 years ago

Yeah its on the mac. I've indeed did reset to go back before the merge. Anyway as its slightly irrelevant to my fix if you're happy with the code lets merge it?

hughperkins commented 8 years ago

Yes, awesome. Thanks!

hughperkins commented 8 years ago

(can reproduce the mac build issue, created an issue for it at https://github.com/hughperkins/clnn/issues/22 )

hughperkins commented 8 years ago

(mac build issue hopefully fixed now; actually not mac-specific it seems. Fixed in https://github.com/hughperkins/clnn/commit/7c83307de34c291bebccb129f27aaa17e0ce406c I think.)

petrjanda commented 8 years ago

Seems like it was a step forward although I am now getting this:

Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lib/libclnn.so
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/init.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/MSECriterion.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/Tanh.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/Pointwise.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/Threshold.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/LogSoftMax.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/ClassNLLCriterion.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/StatefulTimer.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/THCLNN.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/Narrow.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/CMulTable.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/test.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/testSpatialMaxPooling.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/testSpatialConvolutionMM.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/testMSECriterion.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/testSoftMax.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/testLogSoftMax.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lua/clnn/testSpatialAveragePooling.lua
-- Installing: /Users/petr/torch/install/lib/luarocks/rocks/clnn/scm-1/lib/libTHCLNN.dylib
cd build
Updating manifest for /Users/petr/torch/install/lib/luarocks/rocks
clnn scm-1 is now built and installed in /Users/petr/torch/install/ (license: BSD)

libthclnn_searchpath    nil
luajit: /Users/petr/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'
        /Users/petr/torch/install/share/lua/5.1/clnn/THCLNN.lua:11: in main chunk
        [C]: in function 'require'
        /Users/petr/torch/install/share/lua/5.1/clnn/init.lua:5: in main chunk
        [C]: at 0x010adac290
        [C]: at 0x010ad32ad0
hughperkins commented 8 years ago

Hmmmm, right, opened an issue for this at https://github.com/hughperkins/clnn/issues/24