TensorFlow is a deep learning framework with two installed versions to choose from:
- TensorFlow with the CPU support is only recommended to install this version because it is easy to install and very fast (installs in just 5-10 minutes).
- TensorFlow with GPU support if you have an NVIDIA GPU, you can install this version. This version will be much faster. But you also need to install a library for the GPU.
There is no special requirement, so install the CPU version.
There are five ways to install, choose the official recommended virtualenv
.
1. virtualenv就是一个python的虚拟环境,可以很好的把不同python环境的项目隔离开。因为每个环境都会有自己的名字,要切换只用指定名字然后activate,很直观好用。2. native pip就是假定你的电脑没有别的python项目,单纯就是为了tensorflow服务的,所以直接安装在电脑上。3. docker会完全建立一个隔离的tensorflow环境,适用于已经在用docker的项目。4. anaconda应该也是一个创建虚拟环境的工具。5. 直接从源码安装。好处应该就是可以第一时间使用最新版。
Installing TensorFlow is actually installing a Python environment that can run TensorFlow, so you need to install TensorFlow dependent libraries and TensorFlow ontology.
Detailed steps for installing tensorflow in a virtualenv manner:
Installing Pip and Virtualenv
Take a look at your Python version first:
python --version
Then install according to the version:
sudo# for Python 2.7sudo# for Python 3.n
Create a virtualenv for TensorFlow environment
virtualenv# for Python 2.7virtualenv# for Python 3.n
I put it in the user root directory.mkdir ~/tensorflow
Activate the environment you just created
source# bash, sh, ksh, or zsh
Into the environment prepared for the TensorFlow.
PS: If you want to quit, usedeactivate
Installing TensorFlow in a tensorflow virtual environment
easy_install# upgrade pip version to make sure it is >= 8.1pip# for Python 2.7, install latest tensorflow in virtualenv
Download the following files (useless, make a record purely):
The package is installed in total:
Installing collected packages: six, funcsigs, pbr, mock, html5lib, bleach, markdown, numpy, futures, protobuf, werkzeug, tensorflow-tensorboard, backports.weakref, tensorflow
The relevant version information is as follows (log is truncated):
Collecting TensorFlow downloading TENSORFLOW-1.4.1-CP27-CP27MU-MANYLINUX1_X86_64.WHL (40.7MB) Collecting mock>= 2.0.0 (from TensorFlow) downloading MOCK-2.0.0-PY2.PY3-NONE-ANY.WHL (56kB) Collecting tensorflow-tensorboard<0.5.0 , >=0.4.0rc1 (from TensorFlow) downloading TENSORFLOW_TENSORBOARD-0.4.0RC3-PY2-NONE-ANY.WHL (1.7MB) Collecting numpy>=1.12.1 (from TensorFlow) downloading NUMPY-1.14.0-CP27-CP27MU-MANYLINUX1_X86_64.WHL (16.9MB) Collecting Backports.weakref>=1.0rc1 (from TensorFlow) downloading Backports.weakref-1.0.post1-py2.py3-none-any.whlcollecting six>=1.10.0 (from TensorFlow) Downloading Six-1.11.0-py2.py3-none-any.whlcollecting protobuf>=3.3.0 (from TensorFlow) downloading PROTOBUF-3.5.1-CP27-CP27MU-MANYLINUX1_X86_64.WHL (6.4MB) Collecting funcsigs>=1; Python_version < "3.3" (from Mock>=2.0.0->tensorflow) downloading Funcsigs-1.0.2-py2.py3-none-any.whlcollecting pbr>=0.11 (from Mock>=2.0.0->tensorflow) Downloading Pbr-3.1.1-py2.py3-NONE-ANY.WHL (99kB) collecting bleach==1.5.0 (from Tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow) Downloading Bleach-1.5.0-py2.py3-none-any.whlcollecting markdown>=2.6.8 (from tensorflow-tensorboard<0.5.0, >=0.4.0rc1->tensorflow) downloading MARKDOWN-2.6.11-PY2.PY3-NONE-ANY.WHL (78kB) Collecting futures>=3.1.1; Python_version < "3.2" (from Tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow) downloading Futures-3.2.0-py2-none-any.whlcollecting html5lib==0.9999999 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1- >tensorflow) downloading html5lib-0.9999999.tar.gz (889kB) collecting werkzeug>=0.11.10 (from Tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow) Downloading WERKZEUG-0.14.1-PY2.PY3-NONE-ANY.WHL ( 322kB)
PS: If you want to delete TensorFlow, you just need to remove the ~/tensorflow directory of the second step.
Verify that it's loaded, run a Hello world.
importas= tf.constant(‘Hello, TensorFlow!‘= tf.Session()print(sess.run(hello))
Actually quite simple, step by step.
The purpose of my installation is not actually work to use, but I found that I do not understand the various concepts about tensorflow, so even if just run other people give the model also feel foggy.
Installing the TensorFlow on the Linux/ubuntu