LOADING

Follow me

AI(Artificial Intelligence)study之TensorFlow(1)【zoues.com】
三月 30, 2017|DockerPaaS

AI(Artificial Intelligence)study之TensorFlow(1)【zoues.com】

AI(Artificial Intelligence)study之TensorFlow(1)【zoues.com】

人工智能,机器学习,深度学习的研究最近很热。例如:自动驾驶的tesla公司今天获得了腾讯大力支持,购买了它的5%股票。百度也正在五环上测试它的无人驾驶宝马5系。

TensorFlow(简称TF)是Google公司的一把AI训练利器。我的第一个小目标就是配置TF,配置带GPU的牛卡(有多牛,一个显卡要3万多RMB),把MNIST项目跑起来(MNIST是个啥?是个手写数字自动识别的算法),然后对比纯CPU运行和GPU运行的时间,下图就是我想要的效果。

AI(Artificial Intelligence)study之TensorFlow(1)

www.tensorflow.org网站大多数时间访问不了,在下面的链接里可以找到解决办法。https://github.com/tensorflow/tensorflow/issues/3834

下面是TensorFlow官网的安装过程。

Download and Setup

You can install TensorFlow either from our provided binary packages or from the github source.

Requirements

The TensorFlow Python API supports Python 2.7 and Python 3.3+.

The GPU version works best with Cuda Toolkit 8.0 and cuDNN v5. Other versions are supported (Cuda toolkit >= 7.0 and cuDNN >= v3) only when installing from sources. Please see Cuda installation for details. For Mac OS X, please see Setup GPU for Mac.

Cuda很大,要1.2G。 cuDNN需要在developer.nvidia.com免费注册。Python 很简单,直接到官网下载最新版本就可。

Overview

We support different ways to install 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.

If you are familiar with Pip, Virtualenv, Anaconda, or Docker, please feel free to adapt the instructions to your particular needs. The names of the pip and Docker images are listed in the corresponding installation sections.

If you encounter installation errors, see common problems for some solutions.

Pip installation on Windows

TensorFlow supports only 64-bit Python 3.5 on Windows. We have tested the pip packages with the following distributions of Python:

  • Python 3.5 from Anaconda

  • Python 3.5 from python.org.

    NOTE: TensorFlow requires MSVCP140.DLL, which may not be installed on your system. If, when you import tensorflow as tf, you see an error about No module named "_pywrap_tensorflow" and/or DLL load failed, check whether MSVCP140.DLL is in your %PATH% and, if not, you should install the Visual C++ 2015 redistributable (x64 version).

Both distributions include pip. To install the CPU-only version of TensorFlow, enter the following command at a command prompt:

C:/> pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc1-cp35-cp35m-win_amd64.whl

To install the GPU version of TensorFlow, enter the following command at a command prompt:

C:/> pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc1-cp35-cp35m-win_amd64.whl

选择pip安装就可,别的方法没研究。目前还没有GPU,所以选择安装CPU-only version。

选择“开始”-“cmd”-然后运行pip install 那段命令。然后开始安装,安装好的界面如下所示。

AI(Artificial Intelligence)study之TensorFlow(1)

You can now test your installation.

Run TensorFlow from the Command Line

Open a terminal and type the following:

$ 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 >>>

最后就是用pyhton语言来测试。

to be continued.未完待续。

今天笔记中的英文来自:www.tensorflow.org。版权是他们的。

no comments
Share

发表评论