jcjohnson / neural-style

Torch implementation of neural style algorithm
MIT License
18.31k stars 2.7k forks source link

Module 'clnn' not found #424

Open digatester opened 7 years ago

digatester commented 7 years ago

I followed instalation steps and first "th neural-style.lua" test but after trying to generate anything from samples I get:

/root/torch/install/bin/luajit: /root/torch/install/share/lua/5.1/trepl/init.lua:389: module 'clnn' not found:No LuaRocks module found for clnn no field package.preload['clnn'] no file '/root/.luarocks/share/lua/5.1/clnn.lua' no file '/root/.luarocks/share/lua/5.1/clnn/init.lua' no file '/root/torch/install/share/lua/5.1/clnn.lua' no file '/root/torch/install/share/lua/5.1/clnn/init.lua' no file './clnn.lua' no file '/root/torch/install/share/luajit-2.1.0-beta1/clnn.lua' no file '/usr/local/share/lua/5.1/clnn.lua' no file '/usr/local/share/lua/5.1/clnn/init.lua' no file '/root/.luarocks/lib/lua/5.1/clnn.so' no file '/root/torch/install/lib/lua/5.1/clnn.so' no file '/root/torch/install/lib/clnn.so' no file './clnn.so' no file '/usr/local/lib/lua/5.1/clnn.so' no file '/usr/local/lib/lua/5.1/loadall.so' stack traceback: [C]: in function 'error' /root/torch/install/share/lua/5.1/trepl/init.lua:389: in function 'require' neural_style.lua:336: in function 'setup_gpu' neural_style.lua:53: in function 'main' neural_style.lua:601: in main chunk [C]: in function 'dofile' /root/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk [C]: at 0x00406670

... I understood that I am missing clnn module so I tried "luarocks install clnn" but I end with "Please install cltorch from https://github.com/hughperkins/distro-cl" and now I got lost :) I followed installation instruction for distro-cl but it didn't help...

Do you have any suggestion which direction I should go?

Thanks.

htoyryla commented 7 years ago

clnn is only needed if you have a non-NVIDIA GPU which you intend to use using OpenCL.

However, you shouldn't get this error unless you have specified -backend clnn . Don't do that unless you are using clnn.

If you don't have any GPU, or have not installed the necessary drivers, use -gpu -1 to run with CPU only.

digatester commented 7 years ago

Thanks for explanation. I copy-pasted example and didn't noticed "-gpu 0" flag. Now it works correctly in CPU mode. However my intention is to run this with OpenCL (on ATI Radeon) at the end. Do you have any idea why "luarocks install clnn" failed as mentioned in previous question? Thanks!

htoyryla commented 7 years ago

I use an NVIDIA GPU and cannot help with OpenCL. But in general, to install GPU support, one needs to proceed carefully, from the proper drivers upwards in the correct order. You should get in touch with the people using and/or developing the opencl support for torch. Thus, you might get better advice at https://github.com/hughperkins/distro-cl/issues

PS. Just noticed that distro-cl is a version of torch, not an add-on to torch, so if you install it and intend to use it, make sure that you are using it (e.g. when installing luarocks modules and the running neural-style) and not the standard version which you may have installed first. Perhaps better to remove torch, then install distro-cl, test that it works and then install any luarocks you need.

drgrib commented 4 years ago

I installed cltorch and I am trying to run this on a computer with an AMD card but get the same error.

htoyryla commented 4 years ago

The error message says clnn is missing. Did you install it too? Luarocks install clnn.

Otherwise, torch has been discontinued a couple of years ago. Who knows when cltorch was last updated. Even with a new NVIDIA GPU, I find it difficult to install torch these days.

drgrib commented 4 years ago

Whew. It was way more complicated than that to install on a Mac but I did actually have it installed before I posted.

The issue was that I needed to set -backend clnn which was not obvious from the README.md, just a shot in the the dark I made after seeing someone else use -backend nn in this Medium post.

The bigger issue is that it didn't help the speed at all. It was obviously using the GPU because my CPU use went down to normal levels. But I think it was actually slower than CPU mode. I'm running a new 16" Macbook Pro with a dual AMD Radeon Pro 5300M and Intel UHD Graphics 630 setup, so I can't tell if it is actually utilizing the AMD or defaulting to the subpar Intel.

Update: I reran it and it is definitely using the wrong one:

Using OpenCL device: Intel(R) UHD Graphics 630

Despite the fact that I unchecked the Automatic graphics switching setting in my preferences. This might be a setting for OpenCL, though.

I also tried running:

export OPENCV_OPENCL_DEVICE=AMD:GPU

But I still get

Using OpenCL device: Intel(R) UHD Graphics 630

from

luajit -l clnn -e 'clnn.test()'

It may be a quirk of the OpenCL install required on Mac that it just isn't checking OPENCV_OPENCL_DEVICE.