Ubuntu16.04深度学习一键安装脚本(支持tensorflow、keras、caffe)

前端之家收集整理的这篇文章主要介绍了Ubuntu16.04深度学习一键安装脚本(支持tensorflow、keras、caffe)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

引言

深度学习大热,因此很多同学有装机需求。本人在安装了许多台机器后,逐渐总结形成了一个“深度学习一键安装脚本”,可以在新装Ubuntu 16.04上一键安装 CUDA、cudnn、opencv、jupyter、深度学习库tensorflow、keras、caffe和Python编辑器 Pycharm。

脚本内容如下:

echo "One script installation for deep learning."
echo "TomHeaven Presents."
# config
CAFFE_INSTALL=~

echo "1 of 5: Install cuda and cudnn"
# install nvidia driver and cuda
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64.deb
sudo apt-get update
sudo apt-get install -y cuda

# install cudnn
tar -xf cuda.tar.gz
sudo cp cuda/include/* /usr/local/cuda/include/
sudo cp cuda/lib64/* /usr/local/cuda/lib64/
rm -r -f cuda
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/cuda/lib64" | sudo tee -a /etc/profile


# install pip
sudo apt-get install -y python-pip
# chmod for pip installation directories
sudo chmod a+rw -R /usr/lib/python2.7
sudo chmod a+rw -R /usr/local/bin
sudo chmod a+rw -R /usr/local/share
sudo chmod a+rw -R /usr/local/lib/python2.7

# upgrade pip
pip install --upgrade pip
sudo cp /usr/bin/pip /usr/bin/pip.old
sudo apt-get remove -y python-pip
sudo mv /usr/bin/pip.old /usr/bin/pip


echo "2 of 5: Install opencv and others"
# install opencv
sudo apt-get install -y python-opencv libopencv*
# others
sudo apt-get install -y openssh-server vim python-tk iptux
pip install scikit-learn pinyin jupyter

echo "3 of 5: Install tensorflow and keras"
# install tf,keras
pip install tensorflow_gpu-1.2.0rc2-cp27-cp27mu-manylinux1_x86_64.whl
pip install scipy-0.19.0-cp27-cp27mu-manylinux1_x86_64.whl
pip install  h5py keras scikit-image image
# for visualization
sudo apt-get install -y graphviz
pip install pydot


echo "4 of 5: Install caffe"
sudo apt-get install -y cmake
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev
sudo apt-get install -y libboost-system-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev libboost-date-time-dev libboost-atomic-dev libboost-python-dev 
sudo apt-get install -y libgflags-dev libgoogle-glog-dev protobuf-compiler liblmdb-dev libatlas-base-dev doxygen

tar -zxvf caffe.tar.gz
CAFFE_ROOT=$CAFFE_INSTALL/caffe
mv caffe $CAFFE_INSTALL/
cd $CAFFE_ROOT
mkdir build
cd build
cmake ..
make -j $(($(nproc) + 1))
make install

echo "export PYTHONPATH=$CAFFE_ROOT/build/install/python:\$PYTHONPATH" | sudo tee -a /etc/profile

echo "5 of 5: Install pycharm"
# install pycharm
tar -xf pycharm-community-2017.1.3.tar.gz
rm -f ~/.local/share/applications/jetbrains-pycharm-ce.desktop
sudo mv pycharm-community-2017.1.3 /opt/
sudo ln -s -f /opt/pycharm-community-2017.1.3/bin/pycharm.sh /usr/bin/pycharm
# run pycharm
pycharm

用法

链接:http://pan.baidu.com/s/1pKGV9OJ  密码:3tp9
  • 下载所有内容到Ubuntu分区后,修改install.sh脚本的CAFFE_INSTALL=为你需要的caffe安装路径,默认为当前用户的Home文件夹。
  • ubuntu_dl目录打开终端,执行
chmod a+x install.sh
./install.sh

然后输入密码即可。

注意事项

  • 安装过程需要联网。
  • 本脚本仅在新装Ubuntu Kylin 16.04系统测试无误。
  • 脚本使用Ubuntu自带的Python 2.7,请不要安装Anaconda,可能会引发冲突。
  • 安装完成后,在命令行中输入
source /etc/profile
python
import tensorflow
import keras
import caffe

应当无错。注意对/etc/profile修改重启系统后才会全局生效,因此在导入caffe之前需要手动执行它。重启后就无需再手动执行它了。

  • [2017.09.09更新] 华硕(Asus)主板的机器安装前请先看 Ubuntu16.04安装时常见故障及其解决方法中的故障四的解决方法。否则重启系统后有可能遇到循环登录问题。
  • [2017.09.09更新] Tensorflow和CuDNN的升级方法:本文提供的是Tensorflow 1.2和CuDNN5。如果需要Tensorflow 1.3,将脚本第3部分安装Tensorflow的语句改为pip install tensorflow-gpu,另外将还需要cuda.tar.gz文件替换为从Nvidia官网下载的CuDNN6。
原文链接:https://www.f2er.com/ubuntu/351572.html

猜你在找的Ubuntu相关文章