install torch and resnet – image clasification

target: run this command

th classify.lua resnet-101.t7 img1.jpg img2.jpg ...

in this link: https://github.com/facebook/fb.resnet.torch/tree/master/pretrained


first try error:

first error:

 

module ‘cudnn’ not found:No LuaRocks module found for cudnn

then try to install cudnn for torch

I also tried the command (git clone https://github.com/soumith/cudnn.torch.git -b R6 && cd cudnn.torch && luarocks make cudnnscm-1.rockspec) from this link (https://github.com/soumith/cudnn.torch/issues/359)

(for more info, cudnn for torch is from this gitbuh, https://github.com/soumith/cudnn.torch, use the command luarocks make cudnn-scm-1.rockspec above to install it)

then it comes to another error, require to export libcudnn.so.5 to library path

/home/notrobot/torch/install/bin/luajit: /home/notrobot/torch/install/share/lua/5.1/trepl/init.lua:389: /home/notrobot/torch/install/share/lua/5.1/trepl/init.lua:389: /home/notrobot/torch/install/share/lua/5.1/cudnn/ffi.lua:1603: ‘libcudnn (R5) not found in library path. Please install CuDNN from https://developer.nvidia.com/cuDNN Then make sure files named as libcudnn.so.5 or libcudnn.5.dylib are placed in your library load path (for example /usr/local/lib , or manually add a path to LD_LIBRARY_PATH)

Alternatively, set the path to libcudnn.so.5 or libcudnn.5.dylib to the environment variable CUDNN_PATH and rerun torch. For example: export CUDNN_PATH = “/usr/local/cuda/lib64/libcudnn.so.5”

stack traceback: [C]: in function ‘error’ /home/notrobot/torch/install/share/lua/5.1/trepl/init.lua:389: in function ‘require’ neural_style.lua:350: in function ‘setup_gpu’ neural_style.lua:53: in function ‘main’ neural_style.lua:601: in main chunk [C]: in function ‘dofile’ …obot/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk [C]: at 0x00406670

the solution is libcudnn.so does not in you path

type export and see, there is no libcudnn.so

then do this to fix

export CUDNN_PATH=”/usr/local/cuda/lib64/libcudnn.so”

I searched for libcudnn.so.5 but it did not exist in the computer (/usr)(search for that libcudnn)

but the install version is 7 from Nvidia cuda 7

but the lua requires version libcudnn.so.5

the suggested solutio is export CUDNN_PATH=”…..blablabla…/libcudnn.so.5″ but I only found the libcudnn.so so I tried to export that libcudnn.so and it works
and still dont see any libcudnn.so.6 so I end up with export libcudnn.so

 

type export to check again your export, my return would have this line

declare -x CUDNN_PATH=”/usr/local/cuda/lib64/libcudnn.so”

then it fine.

last step: the error message is about missing cunn module
then install it by command
luarocks install cunn

 

okay, try th classify.lua resnet-101.t7 img1.jpg  from this github https://github.com/tngotran/fb.resnet.torch/tree/master/pretrained

with your own jpg image. here are some tries

input orange.jpb and return 0.96% orange confident

tony@tony-W650DC:~/Desktop/facebookRes/fb.resnet.torch/pretrained$ th classify.lua resnet-101.t7 orange.jpg
Found Environment variable CUDNN_PATH = /usr/local/cuda/lib64/libcudnn.so
Classes for orange.jpg
0.96193885803223 orange
0.037967596203089 lemon
3.5206314350944e-05 banana
1.6331021470251e-05 strawberry
1.3297414625413e-05 pineapple, ananas and see the result

input as a bycicle and return a mountain bike for 80% confident.

tony@tony-W650DC:~/Desktop/facebookRes/fb.resnet.torch/pretrained$ th classify.lua resnet-101.t7 izip-path-ladies.jpg
Found Environment variable CUDNN_PATH = /usr/local/cuda/lib64/libcudnn.so
Classes for izip-path-ladies.jpg
0.80185049772263 mountain bike, all-terrain bike, off-roader
0.085175737738609 disk brake, disc brake
0.079297095537186 bicycle-built-for-two, tandem bicycle, tandem
0.022134141996503 moped
0.0066670970991254 tricycle, trike, velocipede

23635423_1989710014379145_168313253_n

conclusion: above all of this, you may need to install torch or lua and cuda from NVIDA first.

the classification pretrained net is good. try to dig more how does it work and how to modify change adapt to your need

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s