TensorFlow installation-ubuntu

Source: Internet
Author: User

Some tensorflow examples under Windows do not run successfully, such as the example in Https://www.tensorflow.org/tutorials/wide to report the following error: '

' Nonetype ' object has no attribute ' bucketize '

Therefore, it is decided to install TF on the Linux environment.

Landlord with the Linux system for UBUNTU-16.04.2-DESKTOP-AMD64, installed in the VirtualBox 5.1.18 version.

Note that the Unbuntu needs to be 64 bit !!! TensorFlow The official installation package currently does not support the 32-bit OS.

1. Configure the PIP environment

1) Install Pip:

sudo apt install python3-pip

2) update pip source

Foreign pip source is not stable, add the domestic watercress pip source

Create a. pip folder in the home directory

mkdir ~/.pip

Then create the pip.conf file under this directory to write the following:

[Global]trusted-host =  Pypi.douban.comindex-url = http://pypi.douban.com/simple

3) upgrade PIP version from 8.1.1 to 9.0.1

Sudo-h PIP3 Install--upgrade pip

2. Download the TensorFlow WHL file and install

Https://pypi.python.org/pypi/tensorflow has a list of TensorFlow versions:

We chose the TensorFlow version that corresponds to Python 3.5. The commands for installing TensorFlow WHL directly are:

Sudo-h PIP3 Install--upgrade https://storage.googleapis.com/tensorflow/linux/cpu/ Tensorflow-1.0.1-cp35-cp35m-linux_x86_64.whl

Due to the large WHL of TensorFlow, it may fail to download due to network instability. can also use Thunderbolt to download WHL, and then install, corresponding to the installation command:

Sudo-h PIP3 Install--upgrade TENSORFLOW-1.0.1-CP35-CP35M-LINUX_X86_64.WHL

The WHL path above is modified according to the actual situation.

Here I install log as follows:

[email protected]:/media/sf_vmshare$ sudo-h pip3 install--upgrade tensorflow-1.0.1-cp35-cp35m-linux_x86_64. WHL processing./tensorflow-1.0.1-cp35-cp35m-linux_x86_64.whlrequirement already up-to-date:six>=1.10.0 in/usr/ Lib/python3/dist-packages (from tensorflow==1.0.1) collecting numpy>=1.11.0 (from tensorflow==1.0.1) Downloading NUMPY-1.12.1-CP35-CP35M-MANYLINUX1_X86_64.WHL (16.8MB) 100% |████████████████████████████████| 16.8MB 66kb/s requirement already up-to-date:wheel>=0.26 in/usr/lib/python3/dist-packages (from tensorflow==1.0.1) Collecting protobuf>=3.1.0 (from tensorflow==1.0.1) downloading PROTOBUF-3.2.0-CP35-CP35M-MANYLINUX1_X86_64.WHL ( 5.6MB) 100% |████████████████████████████████| 5.6MB 174kb/s collecting Setuptools (from protobuf>=3.1.0->tensorflow==1.0.1) downloading SETUPTOOLS-34.3.2-PY2.PY3-NONE-ANY.WHL (389kB) 100% |████████████████████████████████| 399kB 717kb/s collecting packaging>=16.8 (from setuptools->protobuf>=3.1.0->tensorflow==1.0.1) downloading Packaging-16.8-py2.py3-none-any.whlcollecting appdirs>=1.4.0 (from setuptools->protobuf>=3.1.0->tensorflow==1.0.1) Downloading Appdirs-1.4.3-py2.py3-none-any.whlcollecting pyparsing (from packaging>=16.8->setuptools->protobuf>= 3.1.0->tensorflow==1.0.1) downloading PYPARSING-2.2.0-PY2.PY3-NONE-ANY.WHL (56kB) 100% | ████████████████████████████████| 61kB 1.3mb/s Installing collected Packages:numpy, pyparsing, Packaging, Appdirs, Setuptools, Protobuf, TensorFlow Found Existing installation:pyparsing 2.0.3 not uninstalling pyparsing at/usr/lib/python3/dist-packages, outside Environmen T/usr Found Existing installation:setuptools 20.7.0 not uninstalling Setuptools at/usr/lib/python3/dist-packages, O Utside environment/usrsuccessfully installed appdirs-1.4.3 numpy-1.12.1 packaging-16.8 protobuf-3.2.0 pyparsing-2.2.0 setuptools-34.3.2 tensorflow-1.0.1

3. Test the installation effect

To verify the installation effect, let's run a sample of the linear model in Https://www.tensorflow.org/tutorials/wide.

Download all the TensorFlow code from Https://github.com/tensorflow/tensorflow.

Then enter the Tensorflow-master/tensorflow/examples/learn directory. Run:

     python3.5 wide_n_deep_tutorial.py--model_type=wide

Results match expectations:

Note that Python does not work directly, and the default Python is version 2.7.

You can also modify the ~/.BASHRC to add:

Alias python= '/usr/bin/python3.5 '

And then:

SOURCE ~/.BASHRC

This allows you to use the Python command directly later.

If you have a six-pack error, you can install six by executing the following command:

sudo easy_install--upgrade Six

  

  

TensorFlow installation-ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.