Ubuntu16.04 构建opencl+caffe

来源:互联网 发布:js的arguments例子 编辑:程序博客网 时间:2024/06/07 18:10

1. basic settings

sudo apt update && sudo apt upgrade to update your system.sudo apt install python-pipsudo apt install vimsudo apt install gitsudo apt install cmake

2. Install Intel OpenCL SDK and driver. 
Goto https://software.intel.com/en-us/articles/opencl-drivers, download the SDK and driver package. The SDK should have a name like SRB5.0_linux64.zip, and the driver should look like intel_sdk_for_opencl_2017_7.0.0.2511_x64.tgz.
Extract the driver package.

mkdir intel-opencltar -C intel-opencl -Jxf intel-opencl-r5.0-BUILD_ID.x86_64.tar.xztar -C intel-opencl -Jxf intel-opencl-devel-r5.0-BUILD_ID.x86_64.tar.xztar -C intel-opencl -Jxf intel-opencl-cpu-r5.0-BUILD_ID.x86_64.tar.xzsudo cp -R intel-opencl/* /sudo ldconfig

3. Use Intel's CapsBasic example to test for successful installation.
download and extract capsbasic
in Makefile 

add -I /opt/intel/opencl/include -L /opt/intel/opencl
make -j4./capsbasic

__________________________
4. install opencl SDK
sudo apt-get install dkmssudo ./install_GUI.sh
5. install openblas
sudo apt-get install libopenblas-*

__________________________

6. imstall dependencies

sudo apt install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev python-pytest python-numpysudo apt install --no-install-recommends libboost-all-dev

7. Set a directory to install clCaffe.
export CAFFE_ROOT=/a/directory/you/want/clCaffe

add in /home/usr/.bashrc

8. download and compile caffe

git clone https://github.com/01org/caffe $CAFFE_ROOTcd $CAFFE_ROOTmkdir dependencies && cd dependenciesgit clone https://github.com/viennacl/viennacl-dev.gitgit clone https://github.com/intel/isaaccd viennacl-devmkdir build && cd buildcmake -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=$CAFFE_ROOT/dependencies/binaries -DOPENCL_LIBRARY=/opt/intel/opencl/libOpenCL.so ..make -j8sudo make installcd $CAFFE_ROOT/dependencies/isaacmkdir build && cd buildcmake -DCMAKE_INSTALL_PREFIX=$CAFFE_ROOT/dependencies/binaries ..make -j8sudo make installcd $CAFFE_ROOTmkdir build && cd buildexport ISAAC_HOME=$CAFFE_ROOT/dependencies/binariescmake .. -DUSE_GREENTEA=ON -DUSE_CUDA=OFF -DUSE_INTEL_SPATIAL=ON -DBUILD_docs=0 -DUSE_ISAAC=ON -DViennaCL_INCLUDE_DIR=$CAFFE_ROOT/dependencies/binaries/include -DBLAS=open -DOPENCL_LIBRARIES=/opt/intel/opencl/libOpenCL.so -DOPENCL_INCLUDE_DIRS=/opt/intel/opencl/includemake -j8

9. Test the installation.
./tools/caffe device_query -gpu all

and see if there are two OpenCL devices.


10. others

export PYTHONPATH=$CAFFE_ROOT/pythonsudo pip install scikit-imagesudo pip install protobufsudo pip install opencv-pythonsudo pip install lmdb

maybe:
gflags

11. pycaffe
cd $CAFFE_ROOT/pythonfor req in $(cat requirements.txt); do sudo -E pip install $req; done

try python import caffe to test if its right
 
原创粉丝点击