Ubuntu16.04 构建opencl+caffe

本文介绍了如何在Ubuntu 16.04上配置OpenCL并安装Intel的OpenCL SDK和驱动,以用于Caffe框架。首先,从官方网址下载并安装SDK和驱动。接着,通过运行CapsBasic示例来验证安装是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值