install torch and resnet – image clasification

target: run this command

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

in this link:

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 -b R6 && cd cudnn.torch && luarocks make cudnnscm-1.rockspec) from this link (

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

then it comes to another error, require to export 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 Then make sure files named as 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 or libcudnn.5.dylib to the environment variable CUDNN_PATH and rerun torch. For example: export CUDNN_PATH = “/usr/local/cuda/lib64/”

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 does not in you path

type export and see, there is no

then do this to fix

export CUDNN_PATH=”/usr/local/cuda/lib64/”

I searched for 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

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


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

declare -x CUDNN_PATH=”/usr/local/cuda/lib64/”

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

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/
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/
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


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


Leave a Reply

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

You are commenting using your 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