原创

centos上tensorflow一键安装脚本

版权声明:本文为博主原创文章,遵循 CC 4.0 BY 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://lidong.blog.csdn.net/article/details/52084744

鉴于tensorflow在centos上安装相当麻烦,特地制作了一个脚本方便以后移植到其它机器上,脚本含有其它python常用包:

#! /bin/bash  
sudo yum install -y gcc g++ gtk+-devel libjpeg-devel libtiff-devel jasper-devel libpng-devel zlib-devel cmake unzip sqlite-devel readline-devel bzip2-devel openssl-devel ncurses-devel  
sudo yum install -y yum-priorities  
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm  
sudo yum install -y eigen3-devel --enablerepo=epel  
  
su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm'  
sudo yum install -y ffmpeg-devel  
export PYTHON_PREFIX=/usr/local/python-2.7.10  
  
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz  
tar -zxvf Python-2.7.10.tgz  
cd Python-2.7.10  
./configure --enable-shared  --enable-unicode=ucs4 --prefix=$PYTHON_PREFIX CFLAGS="-O3 -fPIC" 
make  
sudo make install  
cd ..  
  
sudo cp $PYTHON_PREFIX/lib/libpython2.7.so.1.0 /usr/local/lib  
sudo ln -s /usr/local/lib/libpython2.7.so.1.0 /usr/local/lib/libpython2.7.so  
sudo echo '/usr/local/lib' > /etc/ld.so.conf  
sudo /sbin/ldconfig  
sudo /sbin/ldconfig -v  
  
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py  
$PYTHON_PREFIX/bin/python get-pip.py  
$PYTHON_PREFIX/bin/pip install -r ./requirements.txt  


#TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
TF_BINARY_URL=https://pypi.python.org/packages/99/72/a420e22dc93416d30981e87a2318823ec09a9b18631369df0e7d9d164073/tensorflow-1.4.0-cp27-cp27mu-manylinux1_x86_64.whl
$PYTHON_PREFIX/bin/pip install –upgrade $TF_BINARY_URL    
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.13.zip  
unzip opencv-2.4.13 
cd opencv-2.4.13  
mkdir build  
cd build  
cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_EXAMPLES=ON -DWITH_EIGEN=ON -DBUILD_NEW_PYTHON_SUPPORT=ON -DINSTALL_PYTHON_EXAMPLES=ON -DPYTHON_EXECUTABLE=$PYTHON_PREFIX/bin/python2.7 -DPYTHON_INCLUDE_DIR=$PYTHON_PREFIX/include/python2.7/ -DPYTHON_LIBRARY=$PYTHON_PREFIX/lib/libpython2.7.so.1.0 -DPYTHON_NUMPY_INCLUDE_DIR=$PYTHON_PREFIX/lib/python2.7/site-packages/numpy/core/include/ -DPYTHON_PACKAGES_PATH=$PYTHON_PREFIX/lib/python2.7/site-packages/ -DBUILD_PYTHON_SUPPORT=ON 
make  
sudo make install


wget http://ftp.gnu.org/pub/gnu/glibc/glibc-2.17.tar.xz
xz -d glibc-2.17.tar.xz
tar -xvf glibc-2.17.tar
cd glibc-2.17
mkdir build
cd build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin  
make && make install


mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
cp libstdc++.so.6.0.20 /usr/lib64/
chmod +x /usr/lib64/libstdc++.so.6.0.20
ln -s /usr/lib64/libstdc++.so.6.0.20 /usr/lib64/libstdc++.so.6
requirements.txt
backports-abc==0.4
backports.shutil-get-terminal-size==1.0.0
backports.ssl-match-hostname==3.5.0.1
certifi==2016.2.28
configparser==3.5.0
decorator==4.0.10
entrypoints==0.2.2
functools32==3.2.3.post2
h5py==2.6.0
ipykernel==4.3.1
ipython==5.0.0
ipython-genutils==0.1.0
Jinja2==2.8
jsonschema==2.5.1
jupyter-client==4.3.0
jupyter-core==4.1.0
Keras==1.0.6
MarkupSafe==0.23
mistune==0.7.3
nbconvert==4.2.0
nbformat==4.0.1
notebook==4.2.1
numpy==1.11.1
pandas==0.18.1
pathlib2==2.1.0
pexpect==4.2.0
pickleshare==0.7.2
Pillow==3.3.0
prompt-toolkit==1.0.3
protobuf==3.0.0b2
ptyprocess==0.5.1
Pygments==2.1.3
pyparsing==2.1.5
pyreadline==2.1
python-dateutil==2.5.3
pytz==2016.4
PyYAML==3.11
pyzmq==15.2.0
qtconsole==4.2.1
scikit-learn==0.17.1
scipy==0.17.1
seaborn==0.7.1
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
tensorflow==0.9.0
terminado==0.6
Theano==0.8.2
tornado==4.3
traitlets==4.2.1
virtualenv==15.0.2
wcwidth==0.1.7
widgetsnbextension==1.2.3

鉴于一些资源获取较难,文中所需要的软件在百度云盘共享里也可以下载到:  http://pan.baidu.com/s/1i5AXoYp

验证是否安装成功,制作test.py
import tensorflow as tf
hello = tf.constant('Hello!')
sess = tf.Session()
print(sess.run(hello))
a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))

执行python test.py能输出Hello! 42就成功了!
0 个人打赏
文章最后发布于: 2016-08-01 14:08:02
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 酷酷鲨 设计师: CSDN官方博客

打赏

开源调度DolphinScheduler

“你的鼓励将是我创作的最大动力”

5C币 10C币 20C币 50C币 100C币 200C币

分享到微信朋友圈

×

扫一扫,手机浏览