{"id":16301,"date":"2020-12-11T18:27:31","date_gmt":"2020-12-11T10:27:31","guid":{"rendered":"http:\/\/blog.idc.net\/16301\/"},"modified":"2020-12-11T18:27:31","modified_gmt":"2020-12-11T10:27:31","slug":"ubuntu-18-04%e6%ba%90%e7%a0%81%e5%ae%89%e8%a3%85caffe%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/16301\/","title":{"rendered":"Ubuntu 18.04\u6e90\u7801\u5b89\u88c5caffe\u6b65\u9aa4"},"content":{"rendered":"<div class=\"idc_table\">\n<p>\u867d\u7136Ubuntu 18.04\u53ef\u4ee5\u901a\u8fc7apt\u5b89\u88c5caffe\uff0c\u4f46\u662f\u4e3a\u4e86\u4f7f\u7528\u6700\u65b0\u7684\u4ee3\u7801\uff0c\u8fd8\u662f\u503c\u5f97\u4ece\u6e90\u7801\u5b89\u88c5\u4e00\u904d\u7684\u3002<\/p>\n<h3>\u5b89\u88c5\u73af\u5883<\/h3>\n<ul>\n<li>OS: Ubuntu 18.04 64 bit<\/li>\n<li>\u663e\u5361: NVidia GTX 1080<\/li>\n<li>CUDA: 10.0<\/li>\n<li>cuDNN: 7.4<\/li>\n<li>Python: 3.6<\/li>\n<\/ul>\n<p>\u4efb\u52a1\uff1a\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5caffe<\/p>\n<h3>\u5b89\u88c5OpenCV<\/h3>\n<h3>\u5b89\u88c5\u4f9d\u8d56<\/h3>\n<pre><code>$ apt install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler\r\n$ apt install -y --no-install-recommends libboost-all-dev\r\n$ apt install -y libatlas-base-dev\r\n$ apt install -y libgflags-dev libgoogle-glog-dev liblmdb-dev<\/code><\/pre>\n<h3>\u4e0b\u8f7d\u6e90\u7801<\/h3>\n<pre><code>$ git clone https:\/\/github.com\/BVLC\/caffe.git\r\n$ cd caffe\r\n$ cp Makefile.config.example Makefile.config<\/code><\/pre>\n<h3>\u66f4\u65b0\u4ee3\u7801<\/h3>\n<p>\u56e0\u4e3a\u4f7f\u7528<code>OpenCV 4.0<\/code>\u7684\u7248\u672c\uff0c\u6240\u4ee5\u6709\u4e9b\u5e38\u91cf\u9700\u8981\u66f4\u65b0\uff1a<\/p>\n<pre><code>CV_LOAD_IMAGE_GRAYSCALE -&gt; cv::ImreadModes::IMREAD_GRAYSCALE\r\nCV_LOAD_IMAGE_COLOR     -&gt; cv::IMREAD_COLOR<\/code><\/pre>\n<p>\u66ff\u6362\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre><code>sed -i 's\/CV_LOAD_IMAGE_COLOR\/cv::IMREAD_COLOR\/g' src\/caffe\/layers\/window_data_layer.cpp\r\nsed -i 's\/CV_LOAD_IMAGE_COLOR\/cv::IMREAD_COLOR\/g' src\/caffe\/util\/io.cpp\r\nsed -i 's\/CV_LOAD_IMAGE_GRAYSCALE\/cv::ImreadModes::IMREAD_GRAYSCALE\/g' src\/caffe\/util\/io.cpp<\/code><\/pre>\n<h3>\u4fee\u6539\u914d\u7f6e<\/h3>\n<p>\u4e3a\u4e86\u4f7f\u7528<code>OpenCV 4.0 + CUDA 10 + cuDNN + python 3.6<\/code>\uff0c\u4fee\u6539<code>Makefile.config<\/code>\u5982\u4e0b\uff1a<\/p>\n<pre><code>...\r\nUSE_CUDNN := 1\r\n...\r\nOPENCV_VERSION := 3\r\n...\r\nCUDA_DIR := \/usr\/local\/cuda-10.0\r\n...\r\nCUDA_ARCH :=    \\\r\n                -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\n# Uncomment to use Python 3 (default is Python 2)\r\nPYTHON_LIBRARIES := boost_python3 python3.6m\r\nPYTHON_INCLUDE := \/usr\/include\/python3.6m \\\r\n                \/usr\/local\/lib\/python3.6\/dist-packages\/numpy\/core\/include\r\n...\r\nWITH_PYTHON_LAYER := 1\r\n...\r\nINCLUDE_DIRS := $(PYTHON_INCLUDE) \/usr\/local\/include \/usr\/include\/hdf5\/serial \/usr\/local\/cuda\/include \/usr\/local\/include\/opencv4\r\nLIBRARY_DIRS := $(PYTHON_LIB) \/usr\/local\/lib \/usr\/lib \/usr\/lib\/x86_64-linux-gnu \/usr\/lib\/x86_64-linux-gnu\/hdf5\/serial<\/code><\/pre>\n<h3>\u7f16\u8bd1caffe<\/h3>\n<pre><code>$ make -j8\r\n$ make pycaffe<\/code><\/pre>\n<p>\u4e00\u5207\u987a\u5229\u7684\u8bdd\uff0c\u751f\u6210\u7684\u5de5\u5177\u5728<code>build\/tools<\/code>\u76ee\u5f55\u4e0b\u3002<\/p>\n<h3>\u9519\u8bef\u5904\u7406<\/h3>\n<p>\u5982\u679c\u62a5\u9519\u5982\u4e0b\uff1a<\/p>\n<pre><code>\/usr\/local\/lib\/libopencv_imgcodecs.so: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'<\/code><\/pre>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<pre><code>$ conda uninstall libtiff<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u867d\u7136Ubuntu 18.04\u53ef\u4ee5\u901a\u8fc7apt\u5b89\u88c5caffe\uff0c\u4f46\u662f\u4e3a\u4e86\u4f7f\u7528\u6700\u65b0\u7684\u4ee3\u7801\uff0c\u8fd8\u662f\u503c\u5f97\u4ece\u6e90\u7801\u5b89\u88c5\u4e00\u904d\u7684\u3002  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-16301","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/16301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=16301"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/16301\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=16301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=16301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=16301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}