{"id":26479,"date":"2021-06-04T18:01:18","date_gmt":"2021-06-04T10:01:18","guid":{"rendered":"http:\/\/www.idc.net\/help\/26479\/"},"modified":"2022-04-29T14:33:03","modified_gmt":"2022-04-29T06:33:03","slug":"ubuntu-18-04%e5%ae%89%e8%a3%85caffe%e5%85%b7%e4%bd%93%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/26479\/","title":{"rendered":"Ubuntu 18.04\u5b89\u88c5caffe\u5177\u4f53\u6b65\u9aa4"},"content":{"rendered":"<div class=\"idc_table\">\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">caffe\u7684\u5168\u79f0\u662fConvolutional Architecture for Fast Feature Embedding\uff08\u8bd1\u4e3a\uff1a\u5feb\u901f\u7279\u5f81\u5d4c\u5165\u7684\u5377\u79ef\u4f53\u7cfb\u7ed3\u6784\uff09\uff0c\u6838\u5fc3\u8bed\u8a00\u662fC++\u3002caffe\u7684\u57fa\u672c\u5de5\u4f5c\u6d41\u7a0b\u662f\u8bbe\u8ba1\u5efa\u7acb\u5728\u795e\u7ecf\u7f51\u7edc\u7684\u4e00\u4e2a\u7b80\u5355\u5047\u8bbe\uff0c\u6240\u6709\u7684\u8ba1\u7b97\u90fd\u662f\u5c42\u7684\u5f62\u5f0f\u8868\u793a\u7684\uff0c\u7f51\u7edc\u5c42\u6240\u505a\u7684\u4e8b\u60c5\u5c31\u662f\u8f93\u5165\u6570\u636e\uff0c\u7136\u540e\u8f93\u51fa\u8ba1\u7b97\u7ed3\u679c\u3002<\/p>\n<p><img decoding=\"async\" style=\"border-radius: 6px;margin: 20px auto;max-width: 95%\" src=\"https:\/\/lxlinux.superbed.verylink.top\/item\/621c5a5b2ab3f51d91124828.png\" class=\"aligncenter\">  <\/p>\n<h2><span style=\"font-size: 18px;font-weight: bold;color: #222;padding-left: 10px;border-left: 5px solid #f83929\">\u5b89\u88c5\u73af\u5883<\/span><\/h2>\n<ul>\n<li>\n<section>\n    OS: Ubuntu 18.04 64 bit<br \/>\n  <\/section>\n<\/li>\n<li>\n<section>\n    \u663e\u5361: NVidia GTX 1080<br \/>\n  <\/section>\n<\/li>\n<li>\n<section>\n    CUDA: 10.0<br \/>\n  <\/section>\n<\/li>\n<li>\n<section>\n    cuDNN: 7.4<br \/>\n  <\/section>\n<\/li>\n<li>\n<section>\n    Python: 3.6<br \/>\n  <\/section>\n<\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">\u4efb\u52a1\uff1a\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5caffe<\/p>\n<h2><span style=\"font-size: 18px;font-weight: bold;color: #222;padding-left: 10px;border-left: 5px solid #f83929\">\u5b89\u88c5OpenCV<\/span><\/h2>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">\u53c2\u8003Ubuntu 18.04\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5OpenCV 4.0\u6b65\u9aa4\uff0c\u5b89\u88c5OpenCV\u3002<\/p>\n<h2><span style=\"font-size: 18px;font-weight: bold;color: #222;padding-left: 10px;border-left: 5px solid #f83929\">\u5b89\u88c5\u4f9d\u8d56<\/span><\/h2>\n<pre><code>$&nbsp;apt&nbsp;install&nbsp;-y&nbsp;libprotobuf-dev&nbsp;libleveldb-dev&nbsp;libsnappy-dev&nbsp;libopencv-dev&nbsp;libhdf5-serial-dev&nbsp;protobuf-compiler\r\n$&nbsp;apt&nbsp;install&nbsp;-y&nbsp;--no-install-recommends&nbsp;libboost-all-dev\r\n$&nbsp;apt&nbsp;install&nbsp;-y&nbsp;libatlas-base-dev\r\n$&nbsp;apt&nbsp;install&nbsp;-y&nbsp;libgflags-dev&nbsp;libgoogle-glog-dev&nbsp;liblmdb-dev\r\n<\/code><\/pre>\n<h2><span style=\"font-size: 18px;font-weight: bold;color: #222;padding-left: 10px;border-left: 5px solid #f83929\">\u4e0b\u8f7d\u6e90\u7801<\/span><\/h2>\n<pre><code>$&nbsp;git&nbsp;<span style=\"color: #0086b3;line-height: 26px\">clone<\/span>&nbsp;https:\/\/github.com\/BVLC\/caffe.git\r\n$&nbsp;<span style=\"color: #0086b3;line-height: 26px\">cd<\/span>&nbsp;caffe\r\n$&nbsp;cp&nbsp;Makefile.config.example&nbsp;Makefile.config\r\n<\/code><\/pre>\n<h2><span style=\"font-size: 18px;font-weight: bold;color: #222;padding-left: 10px;border-left: 5px solid #f83929\">\u66f4\u65b0\u4ee3\u7801<\/span><\/h2>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">\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&nbsp;-&gt;&nbsp;cv::ImreadModes::IMREAD_GRAYSCALE\r\nCV_LOAD_IMAGE_COLOR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;cv::IMREAD_COLOR\r\n<\/code><\/pre>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">\u66ff\u6362\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre><code>sed&nbsp;-i&nbsp;<span style=\"color: #d14;line-height: 26px\">'s\/CV_LOAD_IMAGE_COLOR\/cv::IMREAD_COLOR\/g'<\/span>&nbsp;src\/caffe\/layers\/window_data_layer.cpp\r\nsed&nbsp;-i&nbsp;<span style=\"color: #d14;line-height: 26px\">'s\/CV_LOAD_IMAGE_COLOR\/cv::IMREAD_COLOR\/g'<\/span>&nbsp;src\/caffe\/util\/io.cpp\r\nsed&nbsp;-i&nbsp;<span style=\"color: #d14;line-height: 26px\">'s\/CV_LOAD_IMAGE_GRAYSCALE\/cv::ImreadModes::IMREAD_GRAYSCALE\/g'<\/span>&nbsp;src\/caffe\/util\/io.cpp\r\n<\/code><\/pre>\n<h2><span style=\"font-size: 18px;font-weight: bold;color: #222;padding-left: 10px;border-left: 5px solid #f83929\">\u4fee\u6539\u914d\u7f6e<\/span><\/h2>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">\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&nbsp;:=&nbsp;1\r\n...\r\nOPENCV_VERSION&nbsp;:=&nbsp;3\r\n...\r\nCUDA_DIR&nbsp;:=&nbsp;\/usr\/<span style=\"color: #0086b3;line-height: 26px\">local<\/span>\/cuda-10.0\r\n...\r\nCUDA_ARCH&nbsp;:=&nbsp;&nbsp;&nbsp;&nbsp;\\\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-gencode&nbsp;arch=compute_30,code=sm_30&nbsp;\\\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-gencode&nbsp;arch=compute_35,code=sm_35&nbsp;\\\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-gencode&nbsp;arch=compute_50,code=sm_50&nbsp;\\\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-gencode&nbsp;arch=compute_52,code=sm_52&nbsp;\\\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-gencode&nbsp;arch=compute_60,code=sm_60&nbsp;\\\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-gencode&nbsp;arch=compute_61,code=sm_61&nbsp;\\\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-gencode&nbsp;arch=compute_61,code=compute_61\r\n...\r\n<span style=\"color: #998;font-style: italic;line-height: 26px\">#&nbsp;Uncomment&nbsp;to&nbsp;use&nbsp;Python&nbsp;3&nbsp;(default&nbsp;is&nbsp;Python&nbsp;2)<\/span>\r\nPYTHON_LIBRARIES&nbsp;:=&nbsp;boost_python3&nbsp;python3.6m\r\nPYTHON_INCLUDE&nbsp;:=&nbsp;\/usr\/include\/python3.6m&nbsp;\\\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/usr\/<span style=\"color: #0086b3;line-height: 26px\">local<\/span>\/lib\/python3.6\/dist-packages\/numpy\/core\/include\r\n...\r\nWITH_PYTHON_LAYER&nbsp;:=&nbsp;1\r\n...\r\nINCLUDE_DIRS&nbsp;:=&nbsp;$(PYTHON_INCLUDE)&nbsp;\/usr\/<span style=\"color: #0086b3;line-height: 26px\">local<\/span>\/include&nbsp;\/usr\/include\/hdf5\/serial&nbsp;\/usr\/<span style=\"color: #0086b3;line-height: 26px\">local<\/span>\/cuda\/include&nbsp;\/usr\/<span style=\"color: #0086b3;line-height: 26px\">local<\/span>\/include\/opencv4\r\nLIBRARY_DIRS&nbsp;:=&nbsp;$(PYTHON_LIB)&nbsp;\/usr\/<span style=\"color: #0086b3;line-height: 26px\">local<\/span>\/lib&nbsp;\/usr\/lib&nbsp;\/usr\/lib\/x86_64-linux-gnu&nbsp;\/usr\/lib\/x86_64-linux-gnu\/hdf5\/serial\r\n<\/code><\/pre>\n<h2><span style=\"font-size: 18px;font-weight: bold;color: #222;padding-left: 10px;border-left: 5px solid #f83929\">\u7f16\u8bd1caffe<\/span><\/h2>\n<pre><code>$&nbsp;make&nbsp;-j8\r\n$&nbsp;make&nbsp;pycaffe\r\n<\/code><\/pre>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">\u4e00\u5207\u987a\u5229\u7684\u8bdd\uff0c\u751f\u6210\u7684\u5de5\u5177\u5728<code>build\/tools<\/code>\u76ee\u5f55\u4e0b\u3002<\/p>\n<h2><span style=\"font-size: 18px;font-weight: bold;color: #222;padding-left: 10px;border-left: 5px solid #f83929\">\u9519\u8bef\u5904\u7406<\/span><\/h2>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">\u5982\u679c\u62a5\u9519\u5982\u4e0b\uff1a<\/p>\n<pre><code>\/usr\/<span style=\"color: #0086b3;line-height: 26px\">local<\/span>\/lib\/libopencv_imgcodecs.so:&nbsp;undefined&nbsp;reference&nbsp;to&nbsp;`TIFFReadDirectory@LIBTIFF_4.0<span style=\"color: #d14;line-height: 26px\">' <\/span><\/code><\/pre>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin: 0.8em 0;font-size: 16px;color: #353535\">\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<pre><code>$&nbsp;conda&nbsp;uninstall&nbsp;libtiff\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>caffe\u7684\u5168\u79f0\u662fConvolutional Architecture for Fast Feature Em [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":26480,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,28],"tags":[],"class_list":["post-26479","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/26479","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=26479"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/26479\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/26480"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=26479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=26479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=26479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}