ubuntu14.04配置caffe,cuda8.0+cudnn v6

本文详细介绍了如何安装配置OpenCV 3.2及Caffe,并提供了安装所需的依赖库列表,涵盖了从基本环境配置到CUDA支持的具体步骤,以及如何解决常见问题。

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

1、安装opencv3.2

安装相关的依赖

sudo apt-add-repository universe 
sudo apt update -y && sudo apt upgrade -y
sudo apt-get install -y build-essential make cmake cmake-curses-gui g++ libavformat-dev libavutil-dev libswscale-dev libv4l-dev libeigen3-dev libglew-dev libgtk2.0-dev pkg-config libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev libavcodec-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk-3-dev libatlas-base-dev gfortran python2.7-dev python-pip python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libjasper-dev libdc1394-22-dev ffmpeg
下载opencv3.2和opencv_contrib
cd && wget -O opencv.zip https://github.com/opencv/opencv/archive/3.2.0.zip && unzip opencv.zip
cd && wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.2.0.zip && unzip opencv_contrib.zip
cd opencb-3-2-0
mkdir build && cd build
编译
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules -DWITH_CUDA=ON -DCUDA_ARCH_BIN="5.3" -DCUDA_ARCH_PTX="" -DBUILD_EXAMPLES=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCUDA_FAST_MATH=ON ..
如果make的时候卡在ippicv_linux_20151201.tgz ,则从下面链接中下载ippicv_linux_20151201.tgz ,然后替换opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/下的同名文件,再次cmake,并且make && make install
https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz
2  Install cudnn v6 for cuda 8
tar -zxvf cudnn-8.0-linux-x64-v6.0.tgz
cd cuda
sudo cp cuda/include/*.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64  
cd /usr/local/cuda/lib64
sudo ldconfig -v
3、安装caffe
安装相关依赖
sudo apt-get install libprotobuf-dev protobuf-compiler gfortran libboost-dev cmake libleveldb-dev libsnappy-dev libboost-thread-dev libboost-system-dev libatlas-base-dev libhdf5-serial-dev libgflags-dev libatlas-dev libboost-all-dev libprotobuf-dev libgflags-dev libhdf5-dev libleveldb-dev liblmdb-dev libsnappy-dev python-pip libgoogle-glog-dev liblmdb-dev gcc-4.7 g++-4.7 python-numpy -y
git clone https://github.com/BVLC/caffe.git && cd caffe
sudo cp Makefile.config.example Makefile.config
sudo gedit Makefile.config # Change below status
 USE_CUDNN :=1  # Line 5
 # save
sudo make -j10 all  # Some warning message is OK, don't worry!
sudo make -j10 py
# Test performance
build/tools/caffe time --model=models/bvlc_alexnet/deploy.prototxt --gpu=0  #GPU鐗?
build/tools/caffe time --model=models/bvlc_alexnet/deploy.prototxt       #CPU鐗?
sudo make -j4 test
sudo make -j4 runtest # Optional, take long time
sudo make py
sudo make distribute # Optional

最后用手写数字集测试
# mnist Test
sh data/mnist/get_mnist.sh
sh examples/mnist/create_mnist.sh
./examples/mnist/train_lenet.sh

NVIDIA® cuDNN is a GPU-accelerated library of primitives for deep neural networks. cuDNN是一个对DNN的GPU加速库。他提供高度可调整的在DNN中的常用的例程实现。 It provides highly tuned implementations of routines arising frequently in DNN applications: 常用语前向后向卷积网络,包括交叉相关。Convolution forward and backward, including cross-correlation 前像后向pooling。Pooling forward and backward 前向后向softmax。Softmax forward and backward 前向后向神经元激活。Neuron activations forward and backward Rectified linear (ReLU) Hyperbolic tangent (TANH) Tensor transformation functions LRN, LCN and batch normalization forward and backward cuDNN’s convolution routines aim for performance competitive with the fastest GEMM (matrix multiply) based implementations of such routines while using significantly less memory. cuDNN突出可定制的数据布局,支持灵活的维数排序,跨步,4D子区域for 4D张量作为输入输出。 cuDNN features customizable data layouts, supporting flexible dimension ordering, striding, and subregions for the 4D tensors used as inputs and outputs to all of its routines. This flexibility allows easy integration into any neural network implementation and avoids the input/output transposition steps sometimes necessary with GEMM-based convolutions. cuDNN offers a context-based API that allows for easy multithreading and (optional) interoperability with CUDA streams. cuDNN提供一种基于上下文的API,允许简单的多线程和CDUA流的互用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值