Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

Embed Size (px)

Citation preview

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    1/18

    Neil Z. SHAO's Blog

    To Find Perfect with Imperfect.

    C ffe ! "s#$%& ! OpenC in (indows T)tori l *I+ , Set)p

    Posted on July 15, 2015July 22, 2015 by Neil Z. ShaoThe purpose of this series it to get ca e !h"p#$$ca e.ber%eley&ision.org$' (or%ing in (indo(s in the)ost *uic% and dirty (ay# + ll pro&ide 1' the )odi-ed -le that can be co)piled in (indo(s right a(ay

    2' the &s201/ pro ect that + ) currently using. +n short#

    +nstall 34, oost, 6pen 7.1.3o(nload ca e code (ith &s201/ fro) 8it9ub !h"ps#$$github.co)$initialneil$ca e:&s201/'.2.3o(nload /ryparty.;ip !h"ps#$$dri&e.google.co)$open85 end20PS/Jha7c0785 ?@c'and un;ip to A/rdparty folder.

    /.

    Bdit A a e:&s201/ C 3ebug.props and A a e:&s201/ C Delease.props -les so that the path of 34,oost and 6pen 7 )a%e sense for you. 4lso, the gi&en Aco)pute>50,s)>50 is for EaF(ell

    !h"ps#$$en.(i%ipedia.org$(i%i$EaF(ell>!)icroarchitecture''8P . hange 50 to 20 for Ger)i!h"ps#$$en.(i%ipedia.org$(i%i$Ger)i>!)icroarchitecture''and /0 for Hepler !h"ps#$$en.(i%ipedia.org$(i%i$Hepler>!)icroarchitecture''.

    I.

    6pen ca e:&s201/.sln.5.Set platfor) to Delease, F I and change Aca e pro ect s A on-guration Type to A4pplication !.eFe' ..Dight clic% on Aca e pro ect and Aco)pile .K.Dun test on EN+ST.L.

    Gor ca e.eFe, please use DeleaseMF I )ode. 3ebug &ersion of ca e.eFe )a%es no sense and is slo(./2 bit &ersion should (or% but lac%ing support for l)db and hdf5 because + didn t co)pile the). lol

    Setup#

    34 .5ou ha&e to ha&e a N&idia 8P on your P to enable 8P &ersion of a e. Ey i)pression (as

    that you get )aybe 10F speed:up using 8P o&er P , and another 10F speed:up by enableu3NN !h"ps#$$de&eloper.n&idia.co)$cudnn' library.

    The installation (ill create syste) &ariable for you, e.g. 34>P4T9>7 >5.+f you are using a 8P (ith the architecture of Ger)i or Hepler# 34 .5!h"ps#$$de&eloper.n&idia.co)$cuda:tool%it: 5'

    1.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    2/18

    +f you are using a 8eGorce 8TO FF 8P (ith the architecture of EaF(ell# 34 .5 for EaF(ell!h"ps#$$de&eloper.n&idia.co)$cuda:do(nloads:geforce:gtF FF'Ne(er &ersion of 34 !h"ps#$$de&eloper.n&idia.co)$cuda:tool%it' should be -ne also.

    oostPre:built &ersion of boost are a&ailable. + ) using boost 1.5 .0 )yself. 8et pre:built boost!h"p#$$boost.tee%s .co)$' and install.4dd boost s path to syste) s path. + added 66ST>1>5 >0#

    !h"ps#$$initialneil.-les.(ordpress.co)$2015$0K$syste):&ariable:for:boost1.png'

    2.

    6pen 7Since (e are not using 8P supported 6pen 7 here, e.g. 8puEat, etc. Pre:built &ersion of6pen 7 !h"p#$$sourceforge.net$pro ects$openc&library$-les$openc&:(in$' are good enough for a*uic% start.+ use 6pen 7 /.0 here as eFa)ple. 4dd syste) path &ariable for 6pen 7 also#

    !h"ps#$$initialneil.-les.(ordpress.co)$2015$0K$syste):&ariable:for:openc&.png'

    /.

    Syste) &ariable need Alog o or Arestart your syste) to ta%e e ectI.3o(nload the code for ca e fro) )y 8it9ub !h"ps#$$github.co)$initialneil$ca e:&s201/'

    The original code (as forded fro) KeI 5f2 !h"ps#$$github.co)$ 7Q $ca e$tree$KeI 5f2LLaIaKfc2dKIb2a0a1I5f La0/L 1dcbL'. Then + )anually added the changesfro) R1I1 !h"ps#$$github.co)$ 7Q $ca e$pull$1I1 ' to support &ector EatUV .

    5.

    3o(nload the /rdparty.;ip and un;ip its content to /rdpary folder/rdparty.;ip !7ersion 2015.K.1L' W8oogle 3ri&e !h"ps#$$dri&e.google.co)$open85 end20PS/Jha7c0785 ?@c'X W/ 0 unPan !h"p#$$yunpan.cn$cc@G2Zge/tyY'!code# 1IK'X/rd party.;ip !7ersion 2015.K.15' !h" ps#$$dri&e.google.co)$open85 end20PZ%J;QO737@st@@E '+ncluded is the support for gags , glog , google/protobuf , hdf5 , leveldb , liblmdb , openblas , cudnn , etc.

    .

    efore co)pile !s%ip if you re fa)iliar (ith &s201/ already'#

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    3/18

    @hen it co)es to a big pro ect, )any errors can happen. Qet s get things a bit clear -rst.+n a pro ect, usually functions are declared in .h$.hpp -les and i)ple)ented in .c$.cpp -les. Eissing.hpp -le is usually sho(n in the editor and )issing .cpp -le usually gi&es lin%ing error.4ll .cpp -les added to the &s pro ect (ill be co)piled to .ob -les (hich can be lin%ed later. @hile no.hpp -les (ill be co)piled. 4dding .hpp -les to the &s pro ect or not )a%es no di erence to theco)piling.+f you (ant to include .hpp -le fro) another pro ect, e.g. 6pen 7. ou need to add the path of theheader -les to A4dditional+nclude3irectories .

    4dding header -les to the &s pro ect does N6T add the path auto)atically.4dding the path of .cpp -les to A4dditional+nclude3irectories is N6T needed and has N6 e ect.Gor eFa)ple if the -le path is 3# tool%its openc&:/.0.0 build include openc&2 openc&.hppV,you can either#

    1' add 3# tool%its openc&:/.0.0 build includeV to A4dditional+nclude3irectories and (rite#include “opencv2/opencv.hpp” or2' add 3# tool%its openc&:/.0.0 build include openc&2V to A4dditional+nclude3irectoriesand (rite #include “opencv.hpp”

    4fter the .hpp -le is included, the co)piler %no(s that these functions eFist so Aun%no(n na)espacec& %ind of error (ill not happen any )ore.4fter all .cpp -les in your pro ect are co)piled, here co)es the lin%ing. The i)ple)entation offunctions ha&e to be either in .cpp -les of your pro ect or .lib -les generated by other pro ects.

    Bnabling lib -les re*uires 1' path to be added to A4dditionalQibrary3irectories and 2' -le na)esto be added to A4dditional3ependencies .Gor eFa)ple, you )ight add 3# tool%its openc&:/.0.0 build FL &c12 libV toA4dditionalQibrary3irectories and add openc&>ts/00.lib openc&>(orld/00.lib V toA4dditional3ependencies .

    sually the path of lib -les changes according to the APlatfor)Target , i.e. AFL , and theA on-guration , i.e. A3ebug . + usually let 7isual Studio handle the di erence, e.g. + add

    [!6PBN 7>/>0>0' [!Platfor)Target' &c12 libV for 6pen 7 in later sections.

    +f you sol&e co)pile error by ha&ing proper .hpp -les and sol&e lin%ing error by ha&e proper .lib-les, you progra) (ill run. et it )ight ha&e )issing .dll error.

    So)e library are co)piled in the static (ay to generate .lib -les only, li%e g\ags, protobuf, etc.So)e library are co)piled in the dyna)ic (ay to generate both .lib and .dll -les. +n this case yourprogra) (ill re*uire .dll -les on run:ti)e.Personally + li%e to copy re*uired .dll -les to the sa)e folder of the .eFe -le for si)plicity.

    o)pile#

    6pen the Aca e:&s201/.sln+nProperty Manager you ll see that 2 .props -les are added to the pro ect# A a e:&s201/ C3ebug.props and A a e:&s201/ C Delease.props .

    1.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    4/18

    !h"ps#$$initialneil.-les.(ordpress.co)$2015$0K$property:)anager.png'This is a &ery handy (ay to setup you pro ect *uic%ly. The idea is that so)e -Fedcon-guration are (ri"en in the property sheet -le, i.g. A a e:&s201/ C Delease.props . 4fterthat the pro ect s property, i.e. ADeleaseMF I , can inherit fro) it.

    6pen the A a e:&s201/ C Delease.props fro) dis%, you ll see the se"ing for 34, oost,6pen 7, etc. +f your syste) path for 34, oost, 6pen 7 are di erent fro) )ine, you need tochange the) in these 2 .props -les.6utput folder is changed to A[!Solution3ir'build [!Platfor)' [! on-guration' for later useca e as a lib in other pro ects.Noted that Aco)pute>50,s)>50] in the 2 .props -les )eans the generation of 34 to use. 50(or%s for EaF(ell 8P . se 20 for Ger)i and /0 for Hepler.+f you changed things in the .props -les, you need to close and reopen your &s solution to ta%ee ect.

    Dight clic% on Aca e and clic% AProperty . +n A8eneral :U A on-guration Type , )a%e sure it sA4pplication !.eFe' .

    2.

    Ea%e sure it s Delease and F I. Dight clic% on Aca e and clic% Aco)pile . Aca e.eFe (ill be generatedto Abuild$F I$Delease folder.

    /.

    opy Aopenc&> )peg/00> I.dll , Aopenc&>(orld/00.dll fro) 6pen 7 to the folder of Aca e.eFeI.opy the follo(ing fro) /rdparty folder !be a(are of the con-guration, i.e. 3ebug$Delease,

    @in/2$FL ' to the sa)e folder of Aca e.eFe #libglog.dlllibopenblas.dllcudnn I> 5.dll)s&cp120.dll)s&cr120.dll

    5.

    Dun Aca e.eFe , should display li%e this#.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    0,*-pr*1. 12$2

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    5/18

    !h"ps#$$initialneil.-les.(ordpress.co)$2015$0K$c)d:ca e.png'

    Test on EN+ST

    8o to Aca e$data$)nist folder and run Aget>)nist.bat to fetch dataset for EN+ST.1.8o to Aca e$eFa)ples$)nist folder and

    run Acreate>)nist:le&eldb.bat to con&ert EN+ST dataset to leveldb for)at.run Atrain>lenet:le&eldb.bat to start the training.

    2.

    There s a Al)db &ersion but it does N6T (or%. GiF (as gi&en by a!u"uni osoi here!h"ps#$$initialneil.(ordpress.co)$2015$01$11$build:ca e:in:(indo(s:(ith:&isual:studio:201/:cuda:

    :5:openc&:2:I: $Rco))ent:1I ' but + didn t try it )yself. Not a fan of l)db.

    /.

    Gollo(ing

    !++' se ca e as lib li%e 6pen 7 in a nor)al &s201/ pro ect.

    Posted in ncategori;ed

    - tho)ghts on /C ffe ! "s#$%& ! OpenC in (indows

    0m il for (or12oo1 more profession l with

    c)stom em il from 0oogle Apps.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    6/18

    T)tori l *I+ , Set)p3

    Pingbac%# uild a e in @indo(s (ith 7isual Studio 201/ ^ 34 .5 ^ 6pen 7 2.I. M Neil Z.S946_s log

    1.

    Pingbac%# a e ^ &s201/ ^ 6pen 7 in @indo(s Tutorial !++' M Neil Z. S946_s log2. Amogh Gudi says# July 1 , 2015 at /#02 p)3a)n, you posted this ust i))ediately after + spent installed ca e (ith &s201/ fro) scratch usingyour pre&ious post.

    Deply

    /.

    xy2012 says# July 1L, 2015 at 11#1 a)9i,+ ) fresh in ca e.(hen + 6pen the Aca e:&s201/.sln ,(hy can t + loaded ca e

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    7/18

    + encountered the sa)e proble) as yours. The only di dence is that + a) using @inK insteadof @inL.

    9a&e you %no(n ho( to -F it<

    Neil Z. Shao says# July 1L, 2015 at 1#5 p)9i. The updated /rdparty.;ip -le included the .dll -les for 6pen las. The 0Fc0000Kb error )ight be caused by using /2:bit &ersion .dll -les.

    DeplyDaniel Chen says# July 1L, 2015 at 2#05 p)+ use dependency (al%er to chec% ca e.eFe, it see)s that t(o .dll -les are )issing, (hich r4P+:ES:@+N: 6DB:S9 T36@N:Q1:1:1.3QQV and BOT:ES:@+N:NT SBD: + 6NTBOT:

    BOT:Q1:1:0.3QQV. This error is due to that + ) using (inL.1 instead of lo(er &ersions of(indo(s. 3o u ha&e these t(o .dll -les< They r Ftre)ely hard to -nd 6r;

    1.

    Neil Z. Shao says# July 20, 2015 at #IL a)9i. + ) using (inL.1 also. + ha&e no idea (hy.

    Nick says# Septe)ber I, 2015 at K#/L a)use libgfortran:/.dll fro) /rdparty bin F I Delease

    Deply

    2.

    Jace Lee says# January 1K, 201 at #51 a)i -Fed itcopy /rdparty bin F I Delease .dll -les to (indo( Syste)/2 or (indo( Sys@6@ I

    Deply

    /.

    A un !ala"ee #asude$an says# July 1 , 2015 at I#/ p)Than%s Neil .. our post (as really helpful + use 8P :N7+3+4 8e Gorce L20E !co)putecapability# 2.1', (hich is insu cient for cu3NN to (or% ..So, (hen + run eFa)ples, + get the errorof hec% Gailed# status == 3NN>ST4T S>S BSS ! &s 0'

    3NN>ST4T S>4D 9>E+SE4T 9V +s there any (ay + can (or% (ith your prebuilt binaries, (ithout )a%ing use of cu3NN but running in 8P )ode<

    DeplyNeil Z. Shao says# July 20, 2015 at #IK a)9i 4run. Than%s for using this post. +n the 2 .props -les, there is a E4 D6 SB> 3NNV.Please re)o&e it to disable u3NN.

    Deply A un !ala"ee #asude$an says# July 20, 2015 at L#/5 a)Than%s Neil .+t (or%ed .

    1.

    %eilam says# 3ece)ber 1L, 2015 at L#/5 a)Thans for your eFcellent post. +n ter)s of u3NN, + (onder (here to put the E4 D6

    SB> 3NNV in the eFact place to enable u3NN. 34 $ ^^ :U 96ST :U 4dditionalo)piler 6ptions

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    8/18

    Properties :U $ ^^ :U Preprocessor :U Preprocessor3e-nitionsBn oy

    Cogi&o says# No&e)ber I, 2015 at I#II p)+ had also )et the sa)e proble),though + set the sol&er>)ode A P ,ha&e you sol&ed theproble) yet<

    Deply

    1.

    'uang !in says# July 22, 2015 at 2#52 a)9i, Neil. Than%s for sharing your (or%, but + can t do(nload the /rdparty.;ip !7ersion 2015.K.1L'V,could you send the -le to )y B)ail< Than%s &ery )uch` Ey e)ail is \yinghuangbin g)ail.co).

    DeplyNeil Z. Shao says# July 22, 2015 at /#I0 a)9i a W/ 0 unPanX lin% has been updated.

    Deply 'uang !in says# July 22, 2015 at 5#1 a)could you gi&e )i a lin%. Than%s &ery )uch`

    1.

    Neil Z. Shao says# July 22, 2015 at K#51 a)h"p#$$yunpan.cn$cc@G2Zge/tyY !code# 1IK'

    Deply 'uang !in says# July 22, 2015 at L#I1 a)+ get it. Than% you &ery )uch```

    1.

    K.

    a no says# July 2K, 2015 at 11#05 a)Than%s a lot for this great ob. + did follo( the instructions and ca e.eFe (or%s (ell. Ne&ertheless,(hen + try train:lenet:le&eldb.bat + got this#net.cpp#2KI The netstate phase!0' di ered fro) the phase !1' speci-ed by a rule in layer )nistleading to layer>factory.cpp#25K Qayer )ist has unspeci-ed type.

    4ny help (ould be (elco)e

    Deply Jason says# 4ugust 5, 2015 at L#2L a)9i, + got the sa)e error. 9a&e you sol&ed it<

    Deply

    1.

    Se gey says# 4ugust 5, 2015 at 11#/I p)+ ) ha&ing a sa)e error. 3ebugging also sho(s that assertion failsassert!##ca e##QayerPara)eter>QayerType>+s7alid!&alue'' $$ -le ca e.pb.h, line 2/

    @hen + loo% at QayerPara)eter ob ects, + see the &alid na)es of layers !A)nist , Acon&1 , etc', but,the integer -elds type> all ha&e garbage &alues.+ belie&e it should be 5 for data layer, I for con&olution, etc according to enu)QayerPara)eter>QayerType.

    + ) afraid that protobuf isn t parsed properly, though parsing functions return true.ecause of this c^^ QayerPara)eter ob ects are not -lled correctly.

    2.

    L.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    9/18

    + cannot debug protobuf parsing itself yet as it is in /rd parties (ithout debugging sy)bols.+ ll try to build it )yself and loo% inside a bit later.

    Deply Amogh Gudi says# 4ugust , 2015 at /#2I p)4ny progress on this Qayer )ist has unspeci-ed typeV error<

    1.

    Amogh Gudi says# 4ugust K, 2015 at 12#I2 p)

    9ey 4rno,+ sa( that you also posted co))ents on the neFt part of this tutorial.3oes this )ean that you (ere able to sol&e this Qayer )nist has unspeci-ed typeV error<

    DeplyD agon says# 4ugust 10, 2015 at /#I p)9i,+ replace all the type tag in the lenet>train>test:le&eldb.prototFtV and it (or%s.Qi%e type# 34T4 =U type# dataV

    Ey Bnglish is poor. hope you (ill understand (hat i )ean

    1.

    /.

    (ddd says# 4ugust 20, 2015 at /#1 p)+ )et the sa)e proble). 4nd it is sol&ed by replacing the protoc.eFe in /rdparty to &ersion 2. .0.!The pro&ided protoc.eFe is in &ersion 2. .1'

    Deply&o&o chen says# 4ugust 25, 2015 at 5#/ a)+ ha&e tried replace the protoc.eFe to &ersion 2. .0, but it still didn t (or% .could you send your protoc -le to )e< 6r contact )e (ith detail in e)ail<)y e)ail address is 5 // **.co), than%s```

    1.

    (ddd says# 4ugust 25, 2015 at 2#1/ p)Bssentially this error is caused by the protobuf. So perhaps you can try to generate ca e.pb.ccand ca e.pb.h again.

    2.

    I.

    )m&ia* Ahmed says# 4ugust 2, 2015 at #0K a)i got t(o error (hile co)piling pro ect in &isual studio 2012

    1#:

    Brror /I error # na)espace stdV has no )e)ber signbitV Q# a e ca e:&s201/ ca e

    util )ath>functions.hpp 1I/ 1 ca e2#:

    Brror /5 error ES /K21# The co))and VQ# a e cuda soft bin n&cc.eFeV:gencode=arch=co)pute>50,code= Vs)>50,co)pute>50 V Cuse:local:en& Ccl:&ersion 2012 :ccbin

    3# Eicrosoft 7isual Studio 11.0 7 binV :+Q# a e cuda soft include :+VQ# a e ca e:&s201/ V :+Q# a e boost>1>5 >0 :+Q# a e openc& build include :+VQ# a e ca e:&s201/

    /rdparty includeV :+Q# a e cuda soft include :+Q# a e cuda soft include :8 C%eep:dir3ebug :)aFrregcount=0 C)achine /2 Cco)pile :cudart static :g :3@+N/2 :3>3B 8 :3> 6NS6QB:3>Q+ :3> DT>SB DB>N6>@4DN+N8S :3 SB> 3NN :3> N+ 63B :3 N+ 63B

    .

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    10/18

    :Oco)piler $B9sc $@/ $nologo $6d $Zi $DT 1 $E3d V :o 3ebug )ath>functions.cu.ob Q# a eca e:&s201/ ca e src ca e util )ath>functions.cuVV eFited (ith code 2. # Progra)

    Giles ES uild Eicrosoft. pp &I.0 7110 uild usto)i;ations 34 .5.targets 5 / ca e

    DeplyZe"ia says# Septe)ber 2 , 2015 at #5 p)

    ou can de-ne your o(n signbit func li%e#inline bool signbit>te)p!double nu)' return >copysign!1.0, nu)' 0

    and then replace std##signbit (ith signbit>te)p and the co)pile (ould run.

    Deply

    1.

    Daniel Chen says# 4ugust 5, 2015 at #0 a)9a&e u e&er tried using the python interface, because i can -nd li"le tutorials on it and (hen + try touse it )yself boo) do;ens of error occurred .

    DeplyNeil Z. Shao says# 4ugust , 2015 at 2#01 a)9i. + didn t use python interface. There are so)e other repositories of it + thin%.

    Deply

    10.

    Se gey says# 4ugust 5, 2015 at #5/ p)Than%s for your (or%, Neil.

    + &e tried to build your solution (ith boost 1.5L, but got lin%age errors that 1.5 libs are )issing.+t appears that Ale&eldb.lib fro) your /rd parties is already lin%ed to so)e 1.5 libs, so boost &ersionis not really con-gurable.

    + ha&e also tried cuda K and had ca e.eFe built. ut then disco&ered that your toolAcon&ert>)nist>data.eFe still needs cuda .5 installed.

    @ill you be able to add those /rd party tools to your ca e solution, so that they can be built (ithsa)e dependencies that are easy to s(itch<

    DeplyNeil Z. Shao says# 4ugust , 2015 at 2#00 a)9i. + don t thin% + can pro&ide pre:built libraries for e&ery &ersion of /rd party tools. Pleaseco)pile$get the) (ith your o(n needs.

    Deply

    Se gey says# 4ugust , 2015 at L#25 a)No:no, not prebuilt. + )eant building the) fro) source code too in the ca e solution.9o(e&er, no( + thin% it s not too di-cult to build the) separately.

    4lso, ha&e you seen a proble) that AJason , Aarno and + are facing abo&e<

    1.

    Neil Z. Shao says# 4ugust , 2015 at L#2L a)No, + did not. That s pre"y strange.

    Se gey says# 4ugust , 2015 at 10#I/ a)+ &e tried to build ca e /2bit &ersion and build (ent o% !(ith l)db and hdf5 disabled', but +

    2.

    11.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    1 0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    11/18

    can t start it because there is no libopenblas.dll in (in/2 /rd party. lib -les are there, but dll is)issing !both debug and release'.

    an you please add those to your /rd party< The prebuilt binaries fro) their (ebsite didn thelp. + ) not sure they are binary co)patible.

    Neil Z. Shao says# 4ugust K, 2015 at I#0I a)6pen las (as got fro) o cial site# h"p#$$sourceforge.net$pro ects$openblas$-les$&0.2.12$

    &o&o chen says# 4ugust 2I, 2015 at /#22 p)9i Neil, + ) a beginner of ca e. + ha&e successfully con-g the ca e according to your tutorial, that is +ha&e got the ca e.eFeV and successfully open it. ut (hen + train to train the Qenet!eFecuting the

    train>lenet:le&eldb.batV', at the end of c)d (indo( sho(sV+0L2I 2/#1/#I2.K/ 5I L1/ sol&er.cpp#K2X reating training net fro) net -le#eFa)ples$)nist$lenet>train>test:le&eldb.prototFt+0L2I 2/#1/#I2.KI/551 L1/ net.cpp#2KIX The NetState phase !0' di ered fro) the phase !1' speci-ed by a rule in layer )nist+0L2I 2/#1/#I2.KI/551 L1/ net.cpp#2KIX The NetState phase !0' di ered fro) the phase !1' speci-ed by a rule in layer accuracyG0L2I 2/#1/#I2.KII551 L1/ layer>factory.cpp#25KX Qayer )nist has unspeci-ed type.

    hec% failure stac% trace# V+ speed lots of ti)e still can t -gure it out, could you please tell )e ho( to sol&e this proble)<Than%s a lot```

    Deply

    12.

    &o&o chen says# 4ugust 25, 2015 at #2K a)+ ha&e tried (hat 3ragon and (ddd )entioned, but it still didn t (or%T>>>>TQayer )nist has unspeci-ed type. T>>>>T

    Deply Am u&ha says# Septe)ber , 2015 at I#1L p)9i toto chen,9ad the sa)e proble). + regenerated the ca e.pb.h and ca e>pre"y>print.pb.h by running the8enerateP .bat in the src$ca e$proto directory and + a) not ge"ing that error any)ore. 9opethat helps`

    Deply&o&o chen says# Septe)ber 10, 2015 at 1#22 a)than%s 4)rutha`+ ha&e con-ged it in ubuntu, and it used (ell. than%s any(ay`

    1.

    +as&e says# 3ece)ber 2 , 2015 at I#IL p)Than%s alot, + had the sa)e eFact proble), this also sol&ed )y proble).

    2.

    1.

    1/.

    mingu says# Septe)ber 12, 2015 at #12 p)9i Neil

    1I.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    1 0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    12/18

    i ha&e a proble), so i need your help.

    i )ade the Aca e.eFe

    and it included the dll -les,!openc&> )peg/00> I.dll,openc&>(orld/00.dll,libglog.dll,libopenblas.dll,cudnn I> 5.dll,)s&cp120.dll,)s&cr120.dll' in folder! # ca e:&s201/

    ca e:&s201/ build F I Delease'

    ut (hen you run the Aca e.eFe ,4s soon as the (indo( disappears (hile running.!co)pile step'

    U

    This line is not the )y result(indo(.

    @hat is the proble)<

    DeplyNeil Z. Shao says# Septe)ber 1 , 2015 at 2#II a)+ don t *uite understand. an you open a c)d.eFe -rst and run ca e.eFe (ith it< The (indo((on t close itself this (ay.

    DeplyCogi&o says# No&e)ber I, 2015 at 2#1 p)+ had also )et this proble),(hen + double clic% the Aca e.eFe ,a (indo( disappear in a \ash

    1.

    A. ,ie ce says# Septe)ber 1 , 2015 at 1#I p)Sa)e proble) as )entioned a fe( ti)es before #

    reated ca e.eFeV Then calling train>lenet:le&eldb.batV

    Gollo(ing lines are generated in co))and pro)pt #

    C3# Soft(are NN ca e:&s201/:)aster ca e eFa)ples )nistUDBE go to the ca e root

    3# Soft(are NN ca e:&s201/:)aster ca e eFa)ples )nistUcd ..$..$

    3# Soft(are NN ca e:&s201/:)aster ca eUset +N=..$build$F I$Delease

    3# Soft(are NN ca e:&s201/:)aster ca eUV..$build$F I$Delease$ca e.eFeV trainCsol&er=eFa)ples$)nist$lenet>sol&er:le&eldb.prototFt+0 1 1I#52#//.I5550 K L ca e.cpp# X se 8P (ith de&ice +3 0+0 1 1I#52#//. 2150 K L co))on.cpp#21X Syste) entropy source not a&ailable, using fallbac%algorith) to generate seed instead.+0 1 1I#52#//. 2150 K L ca e.cpp#10KX Starting 6pti)i;ation+0 1 1I#52#//. 2250 K L sol&er.cpp#/KX +nitiali;ing sol&er fro) para)eters#test>iter# 100test>inter&al# 500

    15.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    1 0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    13/18

    base>lr# 0.01display# 100)aF>iter# 10000lr>policy# in&Vga))a# 0.0001po(er# 0.K5)o)entu)# 0.(eight>decay# 0.0005snapshot# 5000snapshot>pre-F# eFa)ples$)nist$lenetVsol&er>)ode# 8Pnet# eFa)ples$)nist$lenet>train>test:le&eldb.prototFtV+0 1 1I#52#//. 2 50 K L sol&er.cpp#K2X reating training net fro) net -le# eFa)ples$)nist$lenet>train>test:le&eldb.prototFt+0 1 1I#52#//. /0510 K L net.cpp#2KIX The NetState phase !0' di ered fro) the phase !1' speci-ed by a rule in layer )nist+0 1 1I#52#//. /0510 K L net.cpp#2KIX The NetState phase !0' di ered fro) the phase !1' speci-ed by a rule in layer accuracyG0 1 1I#52#//. /150 K L layer>factory.cpp#25KX Qayer )nist has unspeci-ed type.

    hec% failure stac% trace# C

    So, + get a crash (hile training.3id already run 8enerateP .batVin ca e:&s201/:)aster ca e src ca e protoV didn t )a%e adi erence.

    @hy can t + ta%e the -nal step

    DeplySon ,ham says# 6ctober L, 2015 at I#2L p)9i 4. Pierce,

    4fter running 8enerateP .bat, you ha&e to co)pile again. The reason is that you ha&e toreco)pile so that all those header are copied into the source code and beco)e part of the ca e.eFeeFecutable. + struggle (ith this a lot because )y ^^ %no(ledge (as far fro) stellar but + hopethis helps`

    Deply

    1.

    San"ay Saini says# Septe)ber 22, 2015 at 12#0 p)

    9ello Neil,Than% you so )uch for sharing a (onderful (or% here ..+ ha&e follo( all the your steps but i a) ge"ing t(o error

    1' 1U # sers research01 3ocu)ents 7isual Studio 201/ Pro ects ca e:&s201/:)asterca e$co))on.hpp!I'# fatal error 10L/# annot open include -le# Aboost$shared>ptr.hpp # No such

    -le or directory

    2' 1U # Progra) Giles !FL ' ES uild Eicrosoft. pp &I.0 7120 uild usto)i;ations 34.5.targets!5 /, '# error ES /K21# The co))and V # Progra) Giles N7+3+4 8P o)puting

    Tool%it 34 & .5 bin n&cc.eFeV :gencode=arch=co)pute>50,code= Vs)>50,co)pute>50 V

    1 .

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    1 0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    14/18

    Cuse:local:en& Ccl:&ersion 201/ :ccbin # Progra) Giles !FL ' Eicrosoft 7isual Studio 12.0 7bin FL >a)d I :+V # Progra) Giles N7+3+4 8P o)puting Tool%it 34 & .5 includeV

    :+V # sers research01 3ocu)ents 7isual Studio 201/ Pro ects ca e:&s201/:)aster V:+ include :+V # sers research01 3ocu)ents 7isual Studio 201/ Pro ects ca e:&s201/:)aster

    /rdparty includeV :+V # Progra) Giles N7+3+4 8P o)puting Tool%it 34 & .5 includeV:+V # Progra) Giles N7+3+4 8P o)puting Tool%it 34 & .5 includeV C%eep:dirF I Delease :)aFrregcount=0 C)achine I Cco)pile :cudart static :3@+N/2 :3N3B 8:3> 6NS6QB :3>Q+ :3 SB>QB7BQ3 :3 SB>QE3 :3 SB>93G5:3> DT>SB DB>N6>@4DN+N8S :3 SB> 3NN :3> N+ 63B :3 N+ 63B :Oco)piler

    $B9sc $@/ $nologo $62 $Zi $E3 V :o F I Delease hdf5>data>layer.cu.ob # sers research013ocu)ents 7isual Studio 201/ Pro ects ca e:&s201/:)aster ca e src ca e layershdf5>data>layer.cuVV eFited (ith code 2.

    +f you can suggest the solution i (ill be &ery grateful to you .

    DeplySan"ay Saini says# Septe)ber 2/, 2015 at 2#52 a)abo&e:)entioned proble) sol&ed . ca e.eFeVsuccessfully generated but it gi&es syste)

    error li%e#ca e.eFe C Syste) errorO The progra) can t start because cudnn I> 5.dll is )issing fro) your co)puter. Tryreinstalling the progra) to -F this proble) .

    4ny idea ho( to -F it .

    Deply

    1.

    -ham / says# 6ctober 1, 2015 at /#1/ a)is boost prebuild and the right &ersion<

    Deply

    2.

    Gu u a" says# 6ctober 1I, 2015 at #0/ a)9i San ay, + got the sa)e error li%e urs. Hindly let )e %no( ho( did u resol&e the abo&e error.

    Deply

    /.

    Gu u a" says# 6ctober 1I, 2015 at #1L a)9ello San ay, + too ha&e the sa)e error .ho( did u resol&e it

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    15/18

    9i NeilGirst o all, than%s for the tutorial, &ery usefull.+ ha&e a si)ple *uestion # (hat &ersion of ca e do you use <

    Deply James says# 6ctober 11, 2015 at 2#5 a)

    an + do this (ithout 34<

    DeplySon ,ham says# 6ctober 11, 2015 at /#1I a)@+thout 34 is actually supposed to be easier. ou ha&e to turn o the P )ode inEa%e.con-g

    Deply James says# 6ctober 11, 2015 at 2#IL p)Than%s for your reply. +s it o% if + ust turn o the 8P )ode< 3on t + ha&e to change anyse"ings for 34< + cannot load Aca e pro ect, and + thin% this is related (ith so)e se"ingsfor 34 pro&ided here. y the (ay, + cannot -nd E4%e.con-g. Than%s`

    1.

    Son ,ham says# 6ctober 11, 2015 at #10 p)+ really apologi;e,

    + (as able to install ca e in both linuF and (indo(s. Ea%e.con-g is so)ething that belongs tothe linuF syste). +t is a &ery si)ple -le (ith the se"ing that you can ust turn on and o forco)pilation. + strongly suggest you do a dual:booth (ith linuF$ubuntu and install ca e theresince there are )uch )ore support for linuF and ubuntu that (ith (indo(s.

    + ) not really (ell:&ersed in 7isual Studio, but + thin% there is a (ay to turn o 34 forco)pilation. 9o(e&er, + (ill suggest to you to actually install 34 & .5 into your syste).

    ou can al(ays turn it o (hen you actually run it. + (ill update to you bac% once + -guredout ho( to turn 34 co)pilation o for (indo(s

    2.

    1.

    1 .

    James says# 6ctober 11, 2015 at L#02 p)+ cannot load Aca pro ect. @hen + try to load it, + )et the follo(ing )essage. + didn t install 34,and + (ant to do this (ith P )ode, but + don t %no( ho( to do.

    nable to read the pro ect -le ca e.&cFpro V. # sers EyNa)e 3ocu)ents 7isual Studio201/ Pro ects ca e:&s201/:)aster ca e ca e.&cFpro !55,5'# The i)ported pro ect # Progra)Giles !FL ' ES uild Eicrosoft. pp &I.0 7120 uild uso)i;ations 34 .5.propsV (as notfound. on-r) that the path in the declaration is correct, and that the -le eFists on dis%.

    Deply

    20.

    ens$age says# 6ctober 21, 2015 at 11#0 p)Than% you so )uch for your sharing. + )et a proble) (hen + used oost>1>5L but not oost>1>5although + changed the path to -nd those 5L.libs. +t al(ays said cannot open >5 .lib. + (onder ifthere s so)ething calling those 5 .libs but + failed to -nd out (here it is. So + ha&e to change bac% to

    oost>1>5 and then proble)s sol&ed. So (ould you please ta%e a loo% at this if you ha&e ti)e<Than% you again for your patience and generosity.

    Deply

    21.

    Cogi&o says# No&e)ber I, 2015 at 1#1/ p)22.

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    1 0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    16/18

    9i,+ )et a proble) described as follo(#ca e$proto$ca e.pb.h! 5/'# error # na)espace google##protobuf##internalV has no )e)ber

    8etB)ptyString4lready+nitedV9o( can + sol&e this proble)

    Deply a anak Sh says# No&e)ber 1I, 2015 at 2#22 p)9i Neil,

    Girst, than% you for the great eFplanation for this tutorial. +t really helps. @hen + open the -le Aca e:&s201/.sln , there are only t(o options of train and test:EN+ST. + ha&e no Aca e as it is sho(n in thepicture. So, + a) stuc% in this stage, as + ha&e no Aca e option#

    2. Dight clic% on Aca e and clic% AProperty . +n A8eneral :U A on-guration Type , )a%e sure it sA4pplication !.eFe' .

    + d be &ery happy if you could help.

    Deplyudy Lu says# 3ece)ber 1, 2015 at L#50 a)

    9ello Garana%,

    + )eet the sa)e error (ith you.

    ou can right clic% on Aca e to edit ca e.&cFpro , then chec% if all paths are correct for your o(ncon-guration.

    + )eet this error because )y 34 s &ersion is K.5 but not .5

    Deply

    1.

    2/.

    kimyoung"u says# 3ece)ber L, 2015 at 1#55 a)+ can not do(nload /rdparty.;ipV in )y o ce. There is so)e -re(all bloc%ing here.

    an you send )e this -le to )e by e:)ail<

    Deply

    2I.

    Se an !odea says# 3ece)ber 15, 2015 at I#2K p)9i Neal,

    + ) trying to co)pile the ca e pro ect but + ) ge"ing the follo(ing error#

    Brror 1 error QNH1112# )odule )achine type AOL con\icts (ith target )achine type AF I# 4GGB ca e:&s201/:)aster ca e libboost>thread:&c120:)t:1>5 .lib!thread.ob ' ca eV

    + ) pre"y sure + con-gured the 3ebug and Delease -les correctly (ould you ha&e so)e ad&ice asto ho( + (or%around this issue<

    Than% you` Serban

    Deply

    25.

    د ن #saysي 3ece)ber 25, 2015 at I#1 p)Nice Tutorial.Than%s.

    2 .

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    0,*-pr*1. 12$2

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    17/18

    Deply3ake&o says# 3ece)ber 2L, 2015 at 11#5 a)9ello `8reat (or%.Than%s for this a)a;ing e ecti&e *uic% tutorial.

    Ta%e care

    Deply

    2K.

    Shisho Sama says# 3ece)ber 2 , 2015 at K#51 a)Than%s alot,+ could get e&erything to (or% but` + get a lin%ing error` ust this#error QNH11L1# cannot open input -le Alibhdf5.lib+ set all library directories for the lin%er!4ctually e&erything (as pre:con-gured than%s to you',e&erything is there, + triple chec%ed it` but still + get that lin%er error, do you %no( (hat could becausing it<

    Deply

    2L.

    4ugene 5u*ne&so$ says# 3ece)ber /0, 2015 at 2#/5 a)Nice (or%` + ust ha&e a couple of issues$obser&ations#

    +t s strange that your code co)piles (ith &s201/. + tried it (ith &s2012 !(hich + d eFpect to be&irtually the sa)e' and it fails because it does not -nd std##isnan, std##signbit and round!'. !The -rstone isn t really needed, and + had to the i)ple)ent the other t(o by hand.'

    our le&eldb.lib in the /rdparty folder is hardcoded to use oost 1.5 . !4s in, it eFpects the eFistenceof se&eral library -les called libboost> :)t:1>5 .lib.' Gor that reason, the pro ect (on t lin% againstany other &ersion of oost. This can be (or%ed around by adding those library -le na)es to

    eFclude default librariesV -eld in lin%er se"ings, and adding correct -le na)es to lin%er input

    libraries.

    B&en (ith that done, it still (on t lin% (ith 7S2012 because + get lin%er con\icts bet(een so)epre:built ob ects and stu that gets co)piled on )y end. + ) do(nloading 7S201/ no(.

    our props -le is loo%ing for openc&>(orld/00.libV. + ha&en t tried 6pen 7 /.0.0, but + ha&e 2.I.and it does not ha&e a openc&>(orld2I .lib. The corresponding -le is, + thin%, openc&>core2I .lib.

    !That said, this is still far be"er than co)piling ca e fro) source in @indo(s C tried to do that, it s adependency hell.'

    Deply4ugene 5u*ne&so$ says# 3ece)ber /1, 2015 at 1#/L a)Qoo%s li%e it can t be lin%ed (ith any oost that s not 1.5 , e&en after )essing (ith libraryeFclusion se"ings. @ith all 1.5 libs eFplicitly eFcluded and 1. 0 libs eFplicitly added to lin%erinput, + get an odd error about boost##-lesyste)##path##generic>string!' being de-ned in t(oplaces !once in le&eldb.lib and once in libboost>-lesyste):&c120:)t:1.> 0.lib'. @ithlibboost>-lesyste):&c120:)t:1.> 0.lib not included, + get tons of unde-ned references.

    Trying to build boost 1.5 no(

    Deply

    1.

    2 .

    + vs2013 + OpenCV in Windows Tutorial (I) – Setup – eil !" """ #ttps$%%initialneil"wordpress"&o'%201 %0 %1 %&affe*vs2013*open&v

    1 0,*-pr*1. 12$

  • 8/18/2019 Caffe + vs2013 + OpenCV in Windows Tutorial (I) – Setup – Neil Z. SHAO's Blog

    18/18

    4ugene 5u*ne&so$ says# 3ece)ber /1, 2015 at K#/K a)uilds correctly (ith 1.5 . 4s for people abo&e, train:lenet:le&eldb.bat fails (ith layer )nist

    has unspeci-ed typeV. 9ad to grab the source of protobuf, rebuild it )anually, replaceheaders, libs and protoc.eFe in /rdparty, run ca e$src$ca e$proto$8enerateP .bat, andreco)pile ca e. 4fter that, it see)s to (or% as intended.

    1.

    ,aka aima says# January , 201 at I#1/ a)+ a) trying to co)pile ca e (ith 7S201/ running in (indo(s K.The ca e pro ect (as built (ithout any errors.@hen + tried to buld the train>EN+ST pro ect, i initially go a )issing ca e.lib (hich (ent a(ay aftercopying theca e.lib to the train>EN+ST release folder.6n subse*uent a"e)pts to build, i get 1 unresol&ed references error li%e the one belo(#

    unresol&ed eFternal sy)bol public# &irtual >>cdecl ca e##Sol&erPara)eter## Sol&erPara)eter!&oid'V!