Based ubuntu16 Python3 tensorflow (TensorFlow environmental structures)

This article describes based ubuntu16 Python3 tensorflow (TensorFlow environment to build), Xiao Bian feel very good, now for everyone to share, but also to be a reference. Come and see, to follow the small series together
one of the greatest strengths is that there are powerful brain. Computers, mobile phones are expanding the human brain. Today, each of us has the opportunity to make their own minds in intelligence help, reach very high altitudes. So, embrace technology to enable us to expand intelligence products become personal intelligence, better to live, to fight.

Study guide with the project:

Our goal is to use the existing Google the most popular open-source framework TensorFlow, to build a children's student helper. Similar to the now existing in the class of goods sold millet intelligent voice box of stuff.

First, install Windows virtual machine under VMware Workstation, is installed in a virtual machine Ubuntu (To make good use of search engines, simple to solve various problems)

Here to provide a VMware Workstation Download: //www.jb51.net/softs/19141.html

Ubuntu official website: https: //www.ubuntu.com/index_kylin

Installation: Here Insert Picture Description
two, mounted in Ubuntu python3

Into the system, right-click the desktop, click open Terminal
Here Insert Picture Description
Here Insert Picture Description
enter the command line mode. Enter python, found that the system comes with python2.7. We want to install python3
Here Insert Picture Description
exit python (with exit ()), enter sudo apt-get install python3, installation python3. Has been pre-installed, the installation is displayed below are python3.5 content, successful installation. Here Insert Picture Description
Third, the installation TensorFlow

有很多种安装方法,可以自行搜索。tensorflow有CPU和GPU两个版本, 后者支持使用GPU能力来做数据运算, 对GPU的型号有一定限制, 还要安装一堆东西, 对于新手,没必要装(官方推荐先装CPU的).

用下面命令安装pip和virtualenv

sudo apt-get install python-pip python-dev python-virtualenv
sudo apt-get install python3-pip python3-dev python3-virtualenv

创建一个virtualenv环境

virtualenv --system-site-packages targetDirectory

注意:这里的”targetDirectory”定义了virtualenv的根目录,这里推荐使用 ~/tensorflow,所以这里的输入是:

virtualenv --system-site-packages ~/tensorflow,

激活刚才创建的virtualenv环境

一般情况下(如果你用的是ubuntu自带的终端或者用的不是csh)输入:source ~/tensorflow/bin/activate12

如果你用的终端是csh,请输入:source ~/tensorflow/bin/activate.csh12

输入命令后,你的命令行前面会出现”(tensorflow)”,如果成功的话.

  1. 现在,在这个已经被激活了的tensorflow环境下,使用下面语句安装tensorflow的cpu版

(tensorflow)$ pip install --upgrade tensorflow # 如果你用 Python 2.7(tensorflow)$ pip3 install --upgrade tensorflow # 如果你用Python3.n
Here Insert Picture DescriptionHere Insert Picture Description
Here Insert Picture Description
安装成功!
五、测试:

1、打开终端输入cd tensorflow

2、source bin/activate

3、python

4、输入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
>>>

5、测试成功接下来首先退出python 按快捷键Ctrl+D

6, and then exit at the command tensorflow enter the command line: deactivate
recommend our python learning sites to see how seniors are learning! From basic python script, reptiles, django, data mining, programming techniques, as well as to combat zero-based sorting data items, given to every love learning python small partner! Python veteran day have to explain the timing of technology, to share some of the ways to learn and need to pay attention to small details, click on Join us python learner gathering

Published 13 original articles · won praise 0 · Views 8684

Guess you like

Origin blog.csdn.net/haoxun06/article/details/104383420