转载请注明来源:http://blog.youkuaiyun.com/greenlight_74110/article/details/78664172
升级python到2.7
- 安装基本开发包
yum groupinstall -y "Development tools"
yum -y install python-devel openssl openssl-devel gcc sqlite sqlite-devel mysql-devel libxml2-devel libxslt-devel
yum install -y zlib-devel bzip2-devel ncurses-devel
- 编译安装python
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar -xvf Python-2.7.9.tgz -C /usr/src
cd /usr/src/Python-2.7.9
./configure --enable-shared
make -j12
make altinstall
- 添加库目录
vi /etc/ld.so.conf
# 末尾添加一行/usr/local/lib
ldconfig
- 替换系统中的python
ls -l `which python python2 python2.6`
rm /usr/bin/python
ln -s -f /usr/local/bin/python2.7 /usr/bin/python
- 保持yum可用性
vim /usr/bin/yum
#!/usr/bin/python 改为 #!/usr/bin/python2.6
附上一份自动安装脚本,安装前需自己观摩后再作相应的修改。
- 安装pip
curl -O https://bootstrap.pypa.io/get-pip.py # 得到一个get-pip.py
python get-pip.py
出现“Successfully installed pip-6.0.8 setuptools-14.3.1为安装成功
- 解决python依赖
pip install 'six>=1.3'
easy_install -U distribute
pip install numpy
pip install pillow
安装blas
yum -y install blas.x86_64 blas-devel.x86_64 \
atlas.x86_64 atlas-devel.x86_64 atlas-sse3.x86_64 atlas-sse3-devel.x86_64
安装opencv
详见这里。
安装boost-1.55
yum -y install libicu.x86_64 libicu-devel.x86_64 bzip2-libs.x86_64 bzip2-devel.x86_64
tar –xf boost_1_55_0.tar.gz && cd boost_1_55_0
./bootstrap.sh
./b2
./b2 install
默认安装在/usr/local/lib目录下,头文件在/usr/local/include/boost目录下。
安装caffe其他依赖:
yum -y install snappy.x86_64 snappy-devel.x86_64 hdf5.x86_64 hdf5-devel.x86_64 epel-release leveldb.x86_64 leveldb-devel.x86_64 libgfortran.x86_64
yum install leveldb-devel snappy-devel hdf5-devel
- 编译安装其它包
wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
tar -xvf protobuf-2.5.0.tar.gz /usr/src/
cd /usr/src/protobuf-2.5.0
./configure
make
make check
make install
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
cd..
# glog
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/google-glog/glog-0.3.3.tar.gz
tar zxvf glog-0.3.3.tar.gz
cd glog-0.3.3
./configure
make && make install
cd ..
# gflags
wget https://github.com/schuhschuh/gflags/archive/master.zip
unzip master.zip
cd gflags-master
mkdir build && cd build
export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1
make && make install
cd ..
# lmdb
git clone https://github.com/LMDB/lmdb
cd lmdb/libraries/liblmdb
make && make install
编译安装caffe
git clone https://github.com/BVLC/caffe.git
安装python依赖包
cd caffe/python
for i in $(cat requirements.txt); do pip install $i; done #需要多执行几遍
- 修改Makefile.config
cp Makefile.config.example Makefile.config
vim Makefile.config
BLAS := atlas
BLAS_LIB := /usr/lib64/atlas
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/site-packages/numpy/core/include \
/usr/local/include/python2.7
- 编译安装
ldconfig
make all -j2
make –j2 pycaffe
make distribute
- 配置pycaffe
vim ~/.bashrc
# 末尾行添加:export PYTHONPATH=$CAFFE_HOME/python:$PYTHONPATH
source ~/.bashrc
- 测试
make test –j2
make runtest –j2
参考:
http://www.ttlsa.com/linux/install-caffe-on-centos6-5/
http://www.centoscn.com/image-text/install/2014/0222/2451.html