ubuntu 编译caffe makefile.config

举报
风吹稻花香 发表于 2021/06/04 23:50:52 2021/06/04
【摘要】 这个是我以前总结的: sudo apt-get install -y libopencv-dev python-opencv sudo apt-get install -y build-essential cmake git pkg-config sudo apt-get install -y libatlas-base-...

这个是我以前总结的:



sudo apt-get install -y libopencv-dev python-opencv
sudo apt-get install -y build-essential cmake git pkg-config

sudo apt-get install -y libatlas-base-dev 
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev 
sudo apt-get install -y python-pip 
sudo apt-get install -y python-dev 
sudo apt-get install -y python-numpy python-scipy
sudo apt-get install -y libboost-all-dev

sudo apt-get update
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev protobuf-compiler
# Check if we have the correct version 2.6
protoc --version

sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install -y python-pip
sudo apt-get install -y python-dev
sudo apt-get install -y python-numpy python-scipy
sudo apt-get install libboost-all-dev
sudo apt-get install python-tk

pip install numpy
pip install cython
pip install scikit-image
pip install protobuf
pip install pyyaml
pip install easydict


首先先用cmake把caffe安装好,这里就省略了这一步。

然后:

sudo apt-get update

sudo apt-get install python-pip python-dev python-numpy

sudo apt-get install gfortran graphviz

sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython

sudo apt-get install protobuf-c-compiler protobuf-compiler

sudo pip install pydot

sudo pip install -r ${CAFFE_ROOT}/python/requirements.txt


安装过程中可能会遇到一些问题,比如要求numpy>X.X(版本号),python-gflags>X.X(版本号),就是一些包的版本太低了。可以把/tmp/pip_build_root/ 目录下对应的文件删除掉,比如sudo rm -rf numpy,然后sudo pip install numpy --upgrade。

然后sudo vim /etc/profile

存入自己的python路径

export PYTHONPATH=~/caffe/python:$PYTHONPATH

source /etc/profile


最后执行python

import caffe

如果成功了就恭喜

如果没成功就根据提醒再解决问题


makefile.config:

## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!


# cuDNN acceleration switch (uncomment to build with cuDNN).
 USE_CUDNN := 1


# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1


# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0


# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#    You should not set this flag if you will be reading LMDBs with any
#    possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1


# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3


# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++


# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda-8.0
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr


# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
        -gencode arch=compute_20,code=sm_21 \
        -gencode arch=compute_30,code=sm_30 \
        -gencode arch=compute_35,code=sm_35 \
        -gencode arch=compute_50,code=sm_50 \
        -gencode arch=compute_52,code=sm_52 \
        -gencode arch=compute_60,code=sm_60 \
        -gencode arch=compute_61,code=sm_61 \
        -gencode arch=compute_61,code=compute_61


# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas


# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib


# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app


# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /home/lbg/anaconda3/include/python3.6m \
        /home/lbg/anaconda3/lib/python3.6/site-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := /home/lbg/anaconda3
 PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
        $(ANACONDA_HOME)/include/python3.6m \
        $(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include


# Uncomment to use Python 3 (default is Python 2)
 PYTHON_LIBRARIES := boost_python-py35 python3.6m
# PYTHON_INCLUDE := /usr/include/python3.5m \
#                 /usr/lib/python3.5/dist-packages/numpy/core/include


# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib


# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib


# Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER := 1


# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include  /usr/local/cuda-8.0/include /usr/include/hdf5/serial/
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib  /usr/local/cuda-8.0/lib /usr/lib/x86_64-linux-gnu/hdf5/serial


# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib


# NCCL acceleration switch (uncomment to build with NCCL)
# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
# USE_NCCL := 1


# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1


# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute


# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1


# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0


# enable pretty build (comment to see full commands)
Q ?= @

sudo apt-get install -y libopencv-dev python-opencv
sudo apt-get install -y build-essential cmake git pkg-config

sudo apt-get install -y libatlas-base-dev 
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev 
sudo apt-get install -y python-pip 
sudo apt-get install -y python-dev 
sudo apt-get install -y python-numpy python-scipy
sudo apt-get install -y libboost-all-dev

sudo apt-get update
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev protobuf-compiler
# Check if we have the correct version 2.6
protoc --version

sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install -y python-pip
sudo apt-get install -y python-dev
sudo apt-get install -y python-numpy python-scipy
sudo apt-get install libboost-all-dev
sudo apt-get install python-tk

pip install numpy
pip install cython
pip install scikit-image
pip install protobuf
pip install pyyaml
pip install easydict


首先先用cmake把caffe安装好,这里就省略了这一步。

然后:

sudo apt-get update

sudo apt-get install python-pip python-dev python-numpy

sudo apt-get install gfortran graphviz

sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython

sudo apt-get install protobuf-c-compiler protobuf-compiler

sudo pip install pydot

sudo pip install -r ${CAFFE_ROOT}/python/requirements.txt


安装过程中可能会遇到一些问题,比如要求numpy>X.X(版本号),python-gflags>X.X(版本号),就是一些包的版本太低了。可以把/tmp/pip_build_root/ 目录下对应的文件删除掉,比如sudo rm -rf numpy,然后sudo pip install numpy --upgrade。

然后sudo vim /etc/profile

存入自己的python路径

export PYTHONPATH=~/caffe/python:$PYTHONPATH

source /etc/profile


最后执行python

import caffe

如果成功了就恭喜

如果没成功就根据提醒再解决问题

文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/jacke121/article/details/80461672

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。