Amazon AWS上Caffe+GPU CUDA 8.0 +cuDNN 5.0 +OpenBLAS+pycaffe配置和lenet训练方法

//环境:Amazon AWS g2.2xlarge实例,Ubuntu 16.04, python2.7, Nvidia cuda 8, cuDNN 5.0, OpenBLAS

 

sudo apt-get update
sudo apt-get install -y python-pip python-numpy python-scipy python-matplotlib
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install -y --no-install-recommends libboost-all-dev
sudo apt-get install -y libopenblas-dev
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install -y unzip cmake


wget https://github.com/BVLC/caffe/archive/master.zip
unzip master.zip
cd caffe-master
cp Makefile.config.example Makefile.config


//安装NVIDIA CUDA Toolkit 8.0
cd ~
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
rm -rf cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install -y cuda


//安装NVIDIA cuDNN库
sudo apt-get install -y lrzsz
https://developer.nvidia.com/rdp/cudnn-download 注册下载 cudnn-8.0-linux-x64-v5.0.tgz
tar -xzvf cudnn-8.0-linux-x64-v5.0-ga.tgz
rm -rf cudnn-8.0-linux-x64-v5.0-ga.tgz
sudo cp -R cuda/lib64/lib* /usr/local/cuda/lib64/
sudo cp cuda/include/cudnn.h /usr/local/cuda/include


#编译安装caffe, pycaffe 
# Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)
cd ~/caffe-master
mkdir build
cd build
cmake -DCPU_ONLY=off -DBLAS=Open ..
make all -j8
make test
make runtest
cd ~/caffe-master/python
for req in $(cat requirements.txt); do pip install $req; done
export PYTHONPATH=~/caffe-master/python:$PYTHONPATH

#测试pycaffe安装是否正确
python
>>import caffe

#训练lenet
cd data/mnist
./get_mnist.sh
cd ../../
./examples/mnist/create_mnist.sh
./examples/mnist/train_lenet.sh
./build/tools/caffe test \
-model examples/mnist/lenet_train_test.prototxt \
-weights examples/mnist/lenet_iter_10000.caffemodel \
-iterations 100
 
#神经网络可视化
/root/caffe-master/python
sudo apt-get install graphviz
pip install pydot
pip install -r requirements.txt

python draw_net.py ../models/bvlc_reference_caffenet/train_val.prototxt caffenet.png

 

参考:

 

1. https://github.com/BVLC/caffe/pull/1667
2. http://www.cnblogs.com/zjutzz/p/6083201.html ILSVRC 2012图像下载。
3. https://www.zybuluo.com/nrailgun/note/488084 数据集
4. http://baike.baidu.com/item/%E6%B5%8B%E8%AF%95%E9%9B%86 测试集的名词解释
5.《深度学习 21天实战Caffe》

 

你可能感兴趣的:(开发工具安装)