{"id":4194,"date":"2019-06-22T12:17:21","date_gmt":"2019-06-22T12:17:21","guid":{"rendered":"http:\/\/www.ipsych.me\/?p=4194"},"modified":"2019-06-22T14:27:10","modified_gmt":"2019-06-22T14:27:10","slug":"install-caffe-with-cuda-support-in-high-sierra","status":"publish","type":"post","link":"https:\/\/www.ipsych.me\/?p=4194","title":{"rendered":"Install Caffe with CUDA support in High Sierra"},"content":{"rendered":"<p>1. Download and install anaconda<\/p>\n<p>2. Download protobuf 3.5.1 source and compile, install.<\/p>\n<p>3. Install Dependencies with homebrew<\/p>\n<pre>brew install -vd snappy leveldb gflags glog szip lmdbhdf5 opencv\r\nbrew install boost@1.59 boost-python@1.59\r\nbrew link boost@1.59 --force\r\nbrew link boost-python@1.59 --force\r\n\r\n4.git clone https:\/\/github.com\/BVLC\/caffe.git\r\n\r\n5.cp Makefile.config.example Makefile.config<\/pre>\n<pre>5.1.<\/pre>\n<pre>USE_CUDNN := 1<\/pre>\n<pre><strong>OPENCV_VERSION: = 3<\/strong><\/pre>\n<pre>CUDA_DIR := \/usr\/local\/cuda\r\n\r\nCUDA_ARCH := -gencode arch=compute_30,code=sm_30 \\\r\n -gencode arch=compute_35,code=sm_35 \\\r\n -gencode arch=compute_50,code=sm_50 \\\r\n -gencode arch=compute_52,code=sm_52 \\\r\n -gencode arch=compute_60,code=sm_60 \\\r\n -gencode arch=compute_61,code=sm_61 \\\r\n -gencode arch=compute_61,code=compute_61\r\n\r\nANACONDA_HOME := $(HOME)\/anaconda\r\nPYTHON_INCLUDE := $(ANACONDA_HOME)\/include \\\r\n $(ANACONDA_HOME)\/include\/python2.7 \\\r\n $(ANACONDA_HOME)\/lib\/python2.7\/site-packages\/numpy\/core\/include\r\n\r\nPYTHON_LIB := $(ANACONDA_HOME)\/lib\r\n\r\n6.change below in makefile\r\nifeq ($(OSX), 1)\r\n CXX := \/usr\/bin\/clang++\r\nto\r\nifeq ($(OSX), 1)\r\n CXX := \/usr\/bin\/clang++ -std=c++11\r\n\r\n<strong>7.export CAFFE_ROOT=\"$HOME\/caffe\"\r\n<\/strong>8. make all -j4\r\n9. make runtest\r\n10.<\/pre>\n<p>install_name_tool -change &#8220;@rpath\/libhdf5_hl.10.dylib&#8221; &#8220;\/Users\/&lt;UserName&gt;\/anaconda\/lib\/libhdf5_hl.10.dylib&#8221; .build_release\/tools\/caffe<br \/>\ninstall_name_tool -change &#8220;@rpath\/libhdf5.10.dylib&#8221; &#8220;\/Users\/&lt;UserName&gt;\/anaconda\/lib\/libhdf5.10.dylib&#8221; .build_release\/tools\/caffe<br \/>\ninstall_name_tool -change &#8220;@rpath\/libcudnn.5.dylib&#8221; &#8220;\/usr\/local\/cuda\/libcudnn.dylib&#8221; .build_release\/tools\/caffe<\/p>\n<p>install_name_tool -change &#8220;@rpath\/libhdf5_hl.10.dylib&#8221; &#8220;\/Users\/&lt;UserName&gt;\/anaconda\/lib\/libhdf5_hl.10.dylib&#8221; .build_release\/test\/test_all.testbin<br \/>\ninstall_name_tool -change &#8220;@rpath\/libhdf5.10.dylib&#8221; &#8220;\/Users\/&lt;UserName&gt;\/anaconda\/lib\/libhdf5.10.dylib&#8221; .build_release\/test\/test_all.testbin<br \/>\ninstall_name_tool -change &#8220;@rpath\/libcudnn.5.dylib&#8221; &#8220;\/usr\/local\/cuda\/libcudnn.dylib&#8221; .build_release\/test\/test_all.testbin<\/p>\n<p>11. make pycaffe<\/p>\n<p>12. make pytest<\/p>\n<p>install_name_tool -change &#8220;@rpath\/libhdf5_hl.10.dylib&#8221; &#8220;\/Users\/&lt;UserName&gt;\/anaconda\/lib\/libhdf5_hl.10.dylib&#8221; python\/caffe\/_caffe.so<br \/>\ninstall_name_tool -change &#8220;@rpath\/libhdf5.10.dylib&#8221; &#8220;\/Users\/&lt;UserName&gt;\/anaconda\/lib\/libhdf5.10.dylib&#8221; python\/caffe\/_caffe.so<br \/>\ninstall_name_tool -change &#8220;@rpath\/libcudnn.5.dylib&#8221; &#8220;\/usr\/local\/cuda\/libcudnn.dylib&#8221; python\/caffe\/_caffe.so<\/p>\n<p>13. to use Matcaffe,<\/p>\n<p>modify makefile.config (the order is matter)!<\/p>\n<p>MATLAB_DIR := \/Applications\/MATLAB_R2017b.app<\/p>\n<p>LIBRARY_DIRS := $(PYTHON_LIB) \/usr\/local\/lib $(MATLAB_DIR)\/bin\/maci64 \/usr\/lib<\/p>\n<pre>\u00a0\r\ninstall_name_tool -change \"@rpath\/libhdf5_hl.10.dylib\" \"\/Users\/&lt;UserName&gt;\/anaconda\/lib\/libhdf5_hl.10.dylib\" matlab\/+caffe\/private\/caffe_.mexmaci64\r\ninstall_name_tool -change \"@rpath\/libhdf5.10.dylib\" \"\/Users\/&lt;UserName&gt;\/anaconda\/lib\/libhdf5.10.dylib\" matlab\/+caffe\/private\/caffe_.mexmaci64<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. Download and install anaconda 2. Download protobuf 3.5.1 source and compile, install. 3. Install Dependencies with homebrew brew install -vd snappy leveldb gflags glog szip lmdbhdf5 opencv brew install boost@1.59 boost-python@1.59 brew link boost@1.59 &#8211;force brew link boost-python@1.59 &#8211;force 4.git clone https:\/\/github.com\/BVLC\/caffe.git 5.cp Makefile.config.example Makefile.config 5.1. USE_CUDNN := 1 OPENCV_VERSION: = 3 CUDA_DIR := [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4194","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/posts\/4194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4194"}],"version-history":[{"count":4,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/posts\/4194\/revisions"}],"predecessor-version":[{"id":4198,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/posts\/4194\/revisions\/4198"}],"wp:attachment":[{"href":"https:\/\/www.ipsych.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}