Install TensorFlow with Anaconda under WIN10

Source: Internet
Author: User

I was in the study of TensorFlow, but also in their own notebooks to complete the installation, in the Pycharm to learn. But recently, in order to use Python's scientific computing environment, I uninstalled the previous environment and reinstalled the TensorFlow with Anaconda, which describes how the CPU version is installed.

Prerequisite check:

    1. In Https://developer.nvidia.com/cuda-gpus confirm that your graphics card supports CUDA, you need to check this step if you are installing a GPU version of TensorFlow.
    2. Make sure that your Python version is 3.5 64 bits.
    3. Make sure you have a stable network connection.
    4. Make sure your pip version is >= 8.1. Use pip -V pip the upgrade to view the current version python -m pip install -U pip pip .
    5. Make sure you have VS2015 or 2013 or 2010 installed. This article is not required, delete.
1. Installing Anaconda

Select the appropriate anaconda to install,: https://www.continuum.io/downloads/, download the corresponding system version of the Anaconda, the current version of the official website is Anaconda 4.4.0 for python3.6. The author installs the version 4.4.0.

As with the installation of ordinary software, all choose the default, note the python3.6 added to the environment variable .

So anaconda is installed, we can use the following command to see which packages Anaconda have installed.
Run 开始菜单->Anaconda3—>Anaconda Prompt :

list

You can see that you have installed NumPy, sympy and other commonly used packages.

2. Installing TensorFlow

TensorFlow currently supports only Python version 3.5 under Windows.

(1) Open Anaconda Prompt, enter the Tsinghua warehouse image, so the update will be faster:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --set show_channel_urls yes

(2) also use Anaconda in Anaconda prompt to create a python3.5 environment, the environment name is TensorFlow, enter the following command:

conda create -n tensorflow python=3.5

Run 开始菜单->Anaconda3—>Anaconda Navigator , click on the left side Environments and you can see tensorflow that the environment has been created well.

(3) Start the TensorFlow environment in Anaconda prompt:

activate tensorflow

Note: When TensorFlow is not used, the TensorFlow environment is closed and the command is:deactivate

(4) Install CPU version of TensorFlow

pip install --upgrade --ignore-installed tensorflow

Note: There is no GPU version of the installation method, GPU version needs to install CUDA8+CUDNN5, if needed, please search other blog posts.

This installs the TensorFlow CPU version as well.

(5) Test TensorFlow
Start the TensorFlow environment in Anaconda prompt and enter the Python environment.

The test code is as follows:

import tensorflow as tfhello = tf.constant(‘Hello, TensorFlow!‘)sess = tf.Session()print(sess.run(hello))

Operation Result:

3. Other issues

Perhaps here we are not satisfied, we in the Anaconda bring the Ipython and Spyder in the import TensorFlow time has failed, prompted No module named ' TensorFlow ', such as, That's because we didn't open them in a tensorflow environment.

In order to be able to use TensorFlow in the Ipython and Spyder, we need to install both plugins in the TensorFlow environment.

Open Anaconda Navigator , select Not installed , find the Ipython and the Spyder and install, the author has been installed here, so it is not shown on this page.

Switch to installed , you can see two have been installed, in fact, can be installed according to their own needs. Show the Spyder that is already installed:

After installing the plugin, we need to test it.

Start the TensorFlow environment in Anaconda prompt and run ipython , import TensorFlow Discover success:

Similarly, start the tensorflow environment in the Anaconda prompt and run Spyder , wait a moment later to start the Spyder Ide,import TensorFlow equally successful:

Note: Be sure to start the Spyder in the TensorFlow environment before you can import TensorFlow, do not go to the Start menu to run the Spyder, where it is not able to run, such as:

Install TensorFlow with Anaconda under WIN10

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.