Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 160948|回复: 0

安装python caffe过程中遇到的一些问题以及对应的解决方案

[复制链接]
  • TA的每日心情
    奋斗
    2024-4-6 11:05
  • 签到天数: 748 天

    [LV.9]以坛为家II

    2034

    主题

    2092

    帖子

    70万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    705612
    发表于 2021-4-8 17:58:52 | 显示全部楼层 |阅读模式

    关于系统环境:

    • Ubuntu 16.04 LTS
    • cuda 8.0
    • cudnn 6.5
    • Anaconda3

    编译pycaffe之前需要配置文件Makefile.config

      1 ## Refer to http://caffe.berkeleyvision.org/installation.html
      2 # Contributions simplifying and improving our build system are welcome!
      3 
      4 # cuDNN acceleration switch (uncomment to build with cuDNN).
      5 USE_CUDNN := 1
      6 
      7 # CPU-only switch (uncomment to build without GPU support).
      8 # CPU_ONLY := 1
      9 
     10 # uncomment to disable IO dependencies and corresponding data layers
     11 # USE_OPENCV := 0
     12 # USE_LEVELDB := 0
     13 # USE_LMDB := 0
     14 
     15 # uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
     16 #    You should not set this flag if you will be reading LMDBs with any
     17 #    possibility of simultaneous read and write
     18 # ALLOW_LMDB_NOLOCK := 1
     19 
     20 # Uncomment if you're using OpenCV 3
     21 # OPENCV_VERSION := 3
     22 
     23 # To customize your choice of compiler, uncomment and set the following.
     24 # N.B. the default for Linux is g++ and the default for OSX is clang++
     25 # CUSTOM_CXX := g++
     26 
     27 # CUDA directory contains bin/ and lib/ directories that we need.
     28 CUDA_DIR := /usr/local/cuda
     29 # On Ubuntu 14.04, if cuda tools are installed via
     30 # "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
     31 # CUDA_DIR := /usr
     32 
     33 # CUDA architecture setting: going with all of them.
     34 # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
     35 # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
     36 CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
     37         -gencode arch=compute_20,code=sm_21 \
     38         -gencode arch=compute_30,code=sm_30 \
     39         -gencode arch=compute_35,code=sm_35 \
     40         -gencode arch=compute_50,code=sm_50 \
     41         -gencode arch=compute_52,code=sm_52 \
     42         -gencode arch=compute_60,code=sm_60 \
     43         -gencode arch=compute_61,code=sm_61 \
     44         -gencode arch=compute_61,code=compute_61
     45 
     46 # BLAS choice:
     47 # atlas for ATLAS (default)
     48 # mkl for MKL
     49 # open for OpenBlas
     50 BLAS := atlas
     51 # Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
     52 # Leave commented to accept the defaults for your choice of BLAS
     53 # (which should work)!
     54 # BLAS_INCLUDE := /path/to/your/blas
     55 # BLAS_LIB := /path/to/your/blas
     56 
     57 # Homebrew puts openblas in a directory that is not on the standard search path
     58 # BLAS_INCLUDE := $(shell brew --prefix openblas)/include
     59 # BLAS_LIB := $(shell brew --prefix openblas)/lib
     60 
     61 # This is required only if you will compile the matlab interface.
     62 # MATLAB directory should contain the mex binary in /bin.
     63 # MATLAB_DIR := /usr/local
     64 # MATLAB_DIR := /Applications/MATLAB_R2012b.app
     65 
     66 # NOTE: this is required only if you will compile the python interface.
     67 # We need to be able to find Python.h and numpy/arrayobject.h.
     68 # PYTHON_INCLUDE := /usr/include/python2.7 \
     69 #        /usr/lib/python2.7/dist-packages/numpy/core/include
     70 # Anaconda Python distribution is quite popular. Include path:
     71 # Verify anaconda location, sometimes it's in root.
     72  ANACONDA_HOME := /home/ipc/anaconda3
     73 # PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
     74 #         $(ANACONDA_HOME)/include/python3.6m \
     75 #         $(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include
     76 # 关键点1:根据自己的情况设置好ANACONDA的路径
    77 # Uncomment to use Python 3 (default is Python 2) 78 PYTHON_LIBRARIES := boost_python3 python3.6m 79 PYTHON_INCLUDE := $(ANACONDA_HOME)/include $(ANACONDA_HOME)/include/python3.6m $(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include 80 # 关键点2:需要注意其中的版本号,原始文件是3.5的,但是我的anaconda是3.6的,因此如果直接uncomment,就会出现问题,需要根据自己的情况设置好
    81 # We need to be able to find libpythonX.X.so or .dylib. 82 # PYTHON_LIB := /usr/lib 83 PYTHON_LIB := $(ANACONDA_HOME)/lib 84 85 # Homebrew installs numpy in a non standard path (keg only) 86 # PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include 87 # PYTHON_LIB += $(shell brew --prefix numpy)/lib 88 89 # Uncomment to support layers written in Python (will link against Python libs) 90 WITH_PYTHON_LAYER := 1 91 92 # Whatever else you find you need goes here. 93 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/lib/x86_64-linux-gnu/hdf5/serial/include /usr/local/cuda/include 94 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial /usr/local/cuda/lib64 95 96 # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies 97 # INCLUDE_DIRS += $(shell brew --prefix)/include 98 # LIBRARY_DIRS += $(shell brew --prefix)/lib 99 100 # NCCL acceleration switch (uncomment to build with NCCL) 101 # https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0) 102 # USE_NCCL := 1 103 104 # Uncomment to use `pkg-config` to specify OpenCV library paths. 105 # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.) 106 # USE_PKG_CONFIG := 1 107 108 # N.B. both build and distribute dirs are cleared on `make clean` 109 BUILD_DIR := build 110 DISTRIBUTE_DIR := distribute 111 112 # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171 113 # DEBUG := 1 114 115 # The ID of the GPU that 'make runtest' will use to run unit tests. 116 TEST_GPUID := 0 117 118 # enable pretty build (comment to see full commands) 119 Q ?= @

     

    1. 如上方式配置文件Makefile.config(路径问题)
      • 可避免Python.h 和 numpy/arrayobject.h文件找不到的问题
    2. cannot find -lboost_python3的问题(版本问题)(参考 http://blog.csdn.net/u012675539/article/details/51351553)
      • 检查是否有文件存在:ls /usr/lib/x86_64-linux-gnu/libboost_python-py35.so 
      • 建立软链接:sudo ln -s libboost_python-py35.so libboost_python3.so
    3. libstdc++.so.6: version 'GLIBCXX_3.4.20' not found的问题 (版本问题)
      • conda install libgcc(conda不能也无需使用sudo)
    4. No module named 'google'的问题 (版本问题)
      • conda install protobuf
    5. 以sudo用户(如sudoxxx)进行安装,其他用户(如otherxxx)进行运行
      • sudo chown otherxxx caffe(权限问题)
      • .bashrc修改环境变量:最后面加入export PYTHONPATH=(你的caffe/python路径,如/home/otherxxx/caffe/python):$PYTHONPATH

     

    上述即为在安装pycaffe过程中所踩过的坑!

     

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-4-27 09:22 , Processed in 0.069251 second(s), 29 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表