TensorFlow 学习-01-TensorFlow在虚拟机Ubuntu64bit上的安装

    xiaoxiao2026-03-04  9

    安装TensorFlow的步骤 1 安装 PIP2 安装 TensorFlow 安装完成后测试

    安装TensorFlow的步骤

    从官网上面可以看到TensorFlow的安装方式主要是如下几种:

    Pip install: Install TensorFlow on your machine, possibly upgrading previously installed Python packages. May impact existing Python programs on your machine. Virtualenv install: Install TensorFlow in its own directory, not impacting any existing Python programs on your machine. Anaconda install: Install TensorFlow in its own environment for those running the Anaconda Python distribution. Does not impact existing Python programs on your machine. Docker install: Run TensorFlow in a Docker container isolated from all other programs on your machine. Installing from sources: Install TensorFlow by building a pip wheel that you then install using pip.

    由于种种原因,最终我选择在ubuntu的虚拟机上面利用Pip install 的方式来进行安装 TensorFlow 的CPU版本。同时还需要就安装Pip的安装包。

    1.1. 安装 PIP

    下载从python (2.7) 的官网下载Pip的 安装包 学习 用tar 解压缩,并且进入到解压目录中

    $ sudo python setup.py install

    完成pip的安装后准备安装TensorFlow。

    $ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl $ sudo pip install --upgrade $TF_BINARY_URL

    1.2. 安装 TensorFlow

    安装 TensorFlow 需要从 storage.googleapis.com/tensorflow 下载一些东西,貌似需要科技上网

    Collecting tensorflow==0.9.0 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl Downloading https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl (27.6MB) 100% |████████████████████████████████| 27.6MB 15kB/s Collecting six>=1.10.0 (from tensorflow==0.9.0) Downloading six-1.10.0-py2.py3-none-any.whl Collecting numpy>=1.8.2 (from tensorflow==0.9.0) Downloading numpy-1.11.1-cp27-cp27mu-manylinux1_x86_64.whl (15.3MB) 100% |████████████████████████████████| 15.3MB 33kB/s Collecting protobuf==3.0.0b2 (from tensorflow==0.9.0) Downloading protobuf-3.0.0b2-py2.py3-none-any.whl (326kB) 100% |████████████████████████████████| 327kB 50kB/s Collecting wheel (from tensorflow==0.9.0) Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB) 100% |████████████████████████████████| 71kB 55kB/s Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/dist-packages/setuptools-25.1.6-py2.7.egg (from protobuf==3.0.0b2->tensorflow==0.9.0) Installing collected packages: six, numpy, protobuf, wheel, tensorflow Found existing installation: six 1.9.0 Uninstalling six-1.9.0: Successfully uninstalled six-1.9.0 Successfully installed numpy-1.11.1 protobuf-3.0.0b2 six-1.10.0 tensorflow-0.9.0 wheel-0.29.0

    完成后就会显示上面红字的这句话,再往上看就可以看到总共下载来上面地四个进度条的东西。

    安装完成后测试

    Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> hello = tf.constant('Hello, the world of TensorFlow!!!!') >>> print_session = tf.Session() >>> print print_session.run(hello) Hello, the world of TensorFlow!!!! >>> x = tf.constant(1.865) >>> y = tf.constant(87.765) >>> print print_session.run(x+y) 89.63
    转载请注明原文地址: https://ju.6miu.com/read-1307600.html
    最新回复(0)