当前位置: 首页 > 工具软件 > OpenCL Caffe > 使用案例 >

Ubuntu16.04 构建opencl+caffe

西门展
2023-12-01

1. basic settings

sudo apt update && sudo apt upgrade to update your system.
sudo apt install python-pip
sudo apt install vim
sudo apt install git
sudo 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-opencl
tar -C intel-opencl -Jxf intel-opencl-r5.0-BUILD_ID.x86_64.tar.xz
tar -C intel-opencl -Jxf intel-opencl-devel-r5.0-BUILD_ID.x86_64.tar.xz
tar -C intel-opencl -Jxf intel-opencl-cpu-r5.0-BUILD_ID.x86_64.tar.xz
sudo 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 dkms
sudo ./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-numpy
sudo 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_ROOT
cd $CAFFE_ROOT
mkdir dependencies && cd dependencies
git clone https://github.com/viennacl/viennacl-dev.git
git clone https://github.com/intel/isaac
cd viennacl-dev
mkdir build && cd build
cmake -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=$CAFFE_ROOT/dependencies/binaries -DOPENCL_LIBRARY=/opt/intel/opencl/libOpenCL.so ..
make -j8
sudo make install
cd $CAFFE_ROOT/dependencies/isaac
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=$CAFFE_ROOT/dependencies/binaries ..
make -j8
sudo make install
cd $CAFFE_ROOT
mkdir build && cd build
export ISAAC_HOME=$CAFFE_ROOT/dependencies/binaries
cmake .. -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/include
make -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/python
sudo pip install scikit-image
sudo pip install protobuf
sudo pip install opencv-python
sudo pip install lmdb

maybe:
gflags

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

try python import caffe to test if its right
 类似资料: