Tensorflow在centos上安装记录

前端之家收集整理的这篇文章主要介绍了Tensorflow在centos上安装记录前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

之前安装过 tensorflow 0.6,还没来得及玩就休假了。回来之后,tensorflow就已经是0.8了,支持分布式训练。于是着手先升级。系统里面之前装caffe,也装过很多tensorflow需要的库,所以一开始安装,各种需求 冲突还是有点头大。


tensorflow有四种安装方式,之前直接用的pip install的方式进行安装。
Pip Install: Install TensorFlow on your machine,possibly upgrading prevIoUsly installedPython packages. May impact existing Python programs on your machine.
Virtualenv Install: Install TensorFlow in its own directory,not impacting any existingPython programs on your machine.
Anaconda install: Install TensorFlow in its own environment for those running the Anaconda Python distribution. Doesnot impact existing Python programs on your machine.
Docker Install: Run TensorFlow in a Docker container isolated from all other programson your machine.


安装方法 : https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#overview
pip install升级到0.8后,发现运行程序很多问题,首先是glib 和 gcc版本过低的问题。 Centos 系统自带的glibc是2.12。按提示升级到2.15,发现还是不行,继续升级到2.17.
#LD_PRELOAD=/usr/lib64/libc-2.17.so rm /lib64/libc.so.6
#LD_PRELOAD=/lib64/libc-2.17.so ln -s /lib64/libc-2.17.so /lib64/libc.so.6
#strings /usr/lib64/libc.so.6|grep GLIBC
......
GLIBC_2.16
GLIBC_2.17
GLIBC_PRIVATE


然后升级gcc,这个过程需要比较小心,如果失败了,那么很多指令都不能使用了。升级
#ln /usr/lib64/libstdc++.so.6.0.21 /usr/lib64/libstdc++.so.6
#strings /usr/local/lib64/libstdc++.so.6|grep GLIBCXX
......
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_FORCE_NEW


然后是安装的protobuf无法识别 :ImportError: No module named protobuf
protobuf安装是成功的,python模块安装出现问题。重装也于事无补,然后选择了virtualenv install的方法,瞬间解决所有问题。
#virtualenv --system-site-packages ~/tensorflow
#source ~/tensorflow/bin/activate


# pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl


Collecting tensorflow==0.8.0 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
/root/tensorflow/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318:
SNIMissingWarning: An HTTPS request has been made,but the SNI (Subject Name Indication) extension to TLS is not
available on this platform. This may cause the server to present an incorrect TLS certificate,which an cause

validation failures. You can upgrade to a newer version of Python to solve this. For more information,see
https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/root/tensorflow/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122:
InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL

appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve

this. For more information,see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

InsecurePlatformWarning Using cached https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl Collecting numpy>=1.8.2 (from tensorflow==0.8.0) /root/tensorflow/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information,see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Using cached numpy-1.11.0-cp27-cp27mu-manylinux1_x86_64.whl Collecting six>=1.10.0 (from tensorflow==0.8.0) Downloading six-1.10.0-py2.py3-none-any.whl Collecting protobuf==3.0.0b2 (from tensorflow==0.8.0) Using cached protobuf-3.0.0b2-py2.py3-none-any.whl Collecting wheel (from tensorflow==0.8.0) Using cached wheel-0.29.0-py2.py3-none-any.whl Collecting setuptools (from protobuf==3.0.0b2->tensorflow==0.8.0) Using cached setuptools-23.0.0-py2.py3-none-any.whl Installing collected packages: numpy,six,setuptools,protobuf,wheel,tensorflow Successfully installed numpy-1.11.0 protobuf-3.0.0a2 setuptools-23.0.0 six-1.10.0 tensorflow-0.8.0 wheel-0.29.0 python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))' /root/tensorflow/lib/python2.7/site-packages/tensorflow 安装完后,先用命令行测试一下 $ python ... >>> import tensorflow as tf >>> hello = tf.constant('Hello,TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello)) Hello,TensorFlow! >>> a = tf.constant(10) >>> b = tf.constant(32) >>> print(sess.run(a + b)) 42 >>> 然后再跑一个实例model #cd /root/tensorflow/lib/python2.7/site-packages/tensorflow/models/image/mnist #python convolutional.py Extracting data/train-images-idx3-ubyte.gz Extracting data/train-labels-idx1-ubyte.gz Extracting data/t10k-images-idx3-ubyte.gz Extracting data/t10k-labels-idx1-ubyte.gz Initialized! Step 0 (epoch 0.00),2.9 ms Minibatch loss: 12.054,learning rate: 0.010000 Minibatch error: 90.6% Validation error: 84.6% ...... #deactivate 原文链接:https://www.f2er.com/centos/381904.html

猜你在找的CentOS相关文章