linux安装caffe记录(非root用户)

①caffe从github下载:执行如下命令:git clone https://github/.../caffe.git

②进入caffe/python目录,安装caffe的python依赖库,执行如下命令:$for req in $(cat requirements.txt); do pip install $req;done

Successfully installed Cython-0.27.3
Requirement already satisfied: numpy>=1.7.1 in /users4/zs/.local/lib/python2.7/site-packages
Requirement already satisfied: numpy>=1.8.2 in /users4/zs/.local/lib/python2.7/site-packages (from scipy>=0.13.2)
Collecting scikit-image>=0.9.3
Collecting matplotlib>=1.3.1 (from scikit-image>=0.9.3)
Collecting networkx>=1.8 (from scikit-image>=0.9.3)
Collecting pillow>=2.1.0 (from scikit-image>=0.9.3)
Requirement already satisfied: six>=1.7.3 in /users4/zs/.local/lib/python2.7/site-packages (from scikit-image>=0.9.3)
Requirement already satisfied: scipy>=0.17.0 in /users4/zs/.local/lib/python2.7/site-packages (from scikit-image>=0.9.3)
Collecting PyWavelets>=0.4.0 (from scikit-image>=0.9.3)
Collecting subprocess32 (from matplotlib>=1.3.1->scikit-image>=0.9.3)
Collecting cycler>=0.10 (from matplotlib>=1.3.1->scikit-image>=0.9.3)
Collecting backports.functools-lru-cache (from matplotlib>=1.3.1->scikit-image>=0.9.3)
Collecting pytz (from matplotlib>=1.3.1->scikit-image>=0.9.3)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib>=1.3.1->scikit-image>=0.9.3)
Requirement already satisfied: numpy>=1.7.1 in /users4/zsun/.local/lib/python2.7/site-packages (from matplotlib>=1.3.1->scikit-image>=0.9.3)
Collecting python-dateutil>=2.0 (from matplotlib>=1.3.1->scikit-image>=0.9.3)
Collecting decorator>=4.1.0 (from networkx>=1.8->scikit-image>=0.9.3)
Building wheels for collected packages: networkx, subprocess32
  Running setup.py bdist_wheel for networkx ... done
  Stored in directory: /users4/zsun/.cache/pip/wheels/c8/58/65/43f97d17a5ba1d88697063234c3ad92ad68885f5f702a20680
  Running setup.py bdist_wheel for subprocess32 ... done
  Stored in directory: /users4/zsun/.cache/pip/wheels/b3/98/13/6760c4255f07fec23c6b22640b1129e57d97b9e736dca5c08b
Successfully built networkx subprocess32
Installing collected packages: subprocess32, cycler, backports.functools-lru-cache, pytz, pyparsing, python-dateutil, matplotlib, decorator, networkx, pillow, PyWavelets, scikit-image
Successfully installed PyWavelets-0.5.2 backports.functools-lru-cache-1.4 cycler-0.10.0 decorator-4.2.1 matplotlib-2.1.1 networkx-2.0 pillow-5.0.0 pyparsing-2.2.0 python-dateutil-2.6.1 pytz-2017.3 scikit-image-0.13.1 subprocess32-3.2.7
Requirement already satisfied: matplotlib>=1.3.1 in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages
Requirement already satisfied: subprocess32 in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages (from matplotlib>=1.3.1)
Requirement already satisfied: cycler>=0.10 in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages (from matplotlib>=1.3.1)
Requirement already satisfied: six>=1.10 in /users4/zs/.local/lib/python2.7/site-packages (from matplotlib>=1.3.1)
Requirement already satisfied: backports.functools-lru-cache in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages (from matplotlib>=1.3.1)
Requirement already satisfied: pytz in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages (from matplotlib>=1.3.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /zs/anaconda3/envs/py27/lib/python2.7/site-packages (from matplotlib>=1.3.1)
Requirement already satisfied: numpy>=1.7.1 in /zs/.local/lib/python2.7/site-packages (from matplotlib>=1.3.1)
Requirement already satisfied: python-dateutil>=2.0 in /zs/anaconda3/envs/py27/lib/python2.7/site-packages (from matplotlib>=1.3.1)
Collecting ipython>=3.0.0 
    Complete output from command python setup.py egg_info:
    IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
    When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
    Beginning with IPython 6.0, Python 3.3 and above is required.
    See IPython `README.rst` file for more information:
        https://github.com/ipython/ipython/blob/master/README.rst
    Python sys.version_info(major=2, minor=7, micro=14, releaselevel='final', serial=0) detected.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-HG651n/ipython/
Collecting h5py>=2.2.0
Requirement already satisfied: numpy>=1.7 in /users4/zs/.local/lib/python2.7/site-packages (from h5py>=2.2.0)
Requirement already satisfied: six in /users4/zs/.local/lib/python2.7/site-packages (from h5py>=2.2.0)
Successfully installed h5py-2.7.1
Successfully installed leveldb-0.194
Requirement already satisfied: networkx>=1.8.1 in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages
Requirement already satisfied: decorator>=4.1.0 in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages (from networkx>=1.8.1)
Successfully installed nose-1.3.7
Collecting pandas>=0.12.0
Requirement already satisfied: pytz>=2011k in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages (from pandas>=0.12.0)
Requirement already satisfied: numpy>=1.9.0 in /users4/zs/.local/lib/python2.7/site-packages (from pandas>=0.12.0)
Requirement already satisfied: python-dateutil in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages (from pandas>=0.12.0)
Requirement already satisfied: six>=1.5 in /users4/zs/.local/lib/python2.7/site-packages (from python-dateutil->pandas>=0.12.0)
Successfully installed pandas-0.22.0
Collecting python-dateutil<2,>=1.4
Building wheels for collected packages: python-dateutil
  Running setup.py bdist_wheel for python-dateutil ... done
  Stored in directory: /users4/zsun/.cache/pip/wheels/83/66/7c/0d6150f3c41e070516cb482e30597ee43e796529909ce23f45
Successfully built python-dateutil
Installing collected packages: python-dateutil
  Found existing installation: python-dateutil 2.6.1
    Uninstalling python-dateutil-2.6.1:
      Successfully uninstalled python-dateutil-2.6.1

Successfully installed python-dateutil-1.5
Requirement already satisfied: protobuf>=2.5.0 in /users4/zs/.local/lib/python2.7/site-packages
Requirement already satisfied: six>=1.9 in /users4/zs/.local/lib/python2.7/site-packages (from protobuf>=2.5.0)
Requirement already satisfied: setuptools in /users4/zs/.local/lib/python2.7/site-packages (from protobuf>=2.5.0)
Successfully installed python-gflags-3.1.2
Requirement already satisfied: pyyaml>=3.10 in /users4/zs/.local/lib/python2.7/site-packages/PyYAML-3.12-py2.7-linux-x86_64.egg
Requirement already satisfied: Pillow>=2.3.0 in /users4/zs/anaconda3/envs/py27/lib/python2.7/site-packages
Requirement already satisfied: six>=1.1.0 in /users4/zs/.local/lib/python2.7/site-packages

③安装依赖

$ yumdownloader protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel gflags-devel glog-devel lmdb-devel

rpm2cpio  以上.rpm |cpio -idvm

$ cp  -rf   ./usr/* ~/usr/

④手动安装其他

1.glog

$ pip install glog
Requirement already satisfied: glog in /users4/zsun/anaconda3/lib/python3.6/site-packages
Requirement already satisfied: six in /users4/zsun/anaconda3/lib/python3.6/site-packages (from glog)
Requirement already satisfied: python-gflags>=3.1 in /users4/zsun/anaconda3/lib/python3.6/site-packages (from glog)

2.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

3.lmdb

git clone https://github.com/LMDB/lmdb 
cd lmdb/libraries/liblmdb 
make && make install

4.protobuf重要

root用户安装步骤请参考 http://blog.csdn.net/tdmyl/article/details/31811317

非root用户参考 http://blog.csdn.net/ccbrid/article/details/79169440

5.hdf5安装

hdf5安装请查看官方文档 
http://www.hdfgroup.org/HDF5/release/obtainsrc.html#src

6.leveldb安装 

leveldb下载请见https://github.com/google/leveldb 
安装请见http://blog.sina.com.cn/s/blog_560e310001015jfx.html 
缺失的步骤: 
leveldb文件夹下依次执行 
make 
cd out-shared 
cp lib* /usr/local/lib

7.OpenBLAS安装OpenBLAS下载链接

下载后,解压,然后安装。  
然后执行下面的指令 
tar -xzvf OpenBLAS.tar.gz 
make 
make PREFIX=~/usr/local/ install 
上述步骤只做参考,实际操作过程可能会存在部分差异,安装的时候注意一下就行 
若在caffe编译的时候出现/usr/bin/ld: cannot find -lopenblas 
请在openblas编译文件夹下执行cp lib* ~/usr/local/lib即可

最终的caffe配置。caffe的github地址为https://github.com/BVLC/caffe 

将工程文件拷贝到本地后,执行

cp Makefile.config.example Makefile.config 
vim ./Makefile.config 
修改CUDA_DIR :=/usr/local/cuda-7.5 (按照个人之前安装cuda的路径进行配置) 
修改BLAS := open 
修改BLAS_INCLUDE,BLAS_LIB为安装路径 
保存(如果用户显卡不够用,可以去除前面的CPU_ONLY :=1前面的注释符号”#”,表示只使用CPU做运算)

接下来就可以正常的执行

make all 如果编译速度慢,可以使用make all -jN (N为核心处理器的个数) 
make test 对编译结果进行测试

下面需要对用户根目录下的.bashrc文件进行编辑,加载一些动态库

vim ~/.bashrc 
文本最后加入 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/glog/lib 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

再次进入caffe目录,执行make runtest

参考http://blog.csdn.net/s2392735818/article/details/49796017

要在Linux安装Caffe,您可以按照以下步骤进行操作: 1. 安装依赖项:首先,确保您的系统已经安装了必要的依赖项。执行以下命令来安装这些依赖项: ``` sudo apt-get update sudo apt-get install build-essential cmake git libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libatlas-base-dev libgflags-dev libgoogle-glog-dev liblmdb-dev ``` 2. 克隆Caffe存储库:使用git命令克隆Caffe存储库。执行以下命令: ``` git clone https://github.com/BVLC/caffe.git ``` 3. 编译和安装Caffe:进入Caffe目录,并根据您的需求进行配置和编译。执行以下命令: ``` cd caffe cp Makefile.config.example Makefile.config # 根据需要编辑Makefile.config文件 make all -j$(nproc) # 编译Caffe make test -j$(nproc) # 运行测试(可选) make runtest -j$(nproc) # 运行完整的测试套件(可选) make pycaffe -j$(nproc) # 编译Python接口(可选) sudo make install # 安装Caffe到系统路径(可选) ``` 4. 配置环境变量:将Caffe添加到系统的环境变量中,以便您可以在任何位置运行它。编辑您所使用的shell配置文件(例如~/.bashrc)并添加以下行: ``` export CAFFE_ROOT=/path/to/caffe export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH ``` 5. 完成安装:保存并关闭配置文件后,执行以下命令使更改生效: ``` source ~/.bashrc ``` 现在,您已经在Linux上成功安装Caffe。您可以使用Caffe提供的命令和接口来构建和训练深度学习模型。请根据您的需求进行进一步的配置和使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值