[PYTHON] How to install the deep learning framework Tensorflow 1.0 in the Anaconda environment of Windows

Introduction

Until now, we used Keras as a backend to run Tensorflow for deep learning. If you just want to do machine learning with Python, you can still use Keras, but there are some uses where you want to use the models and weights learned in Python in C ++. Actually, it would be nice to use the model trained in Keras, but it seems easier to code directly with Tensorflow, which also has a C ++ API, so I will attack from there. First of all, as a preliminary preparation, I will summarize up to the point of installing Tensorflow in the environment of Anaconda built on Windows and checking it. The function names have changed significantly since Tensorflow 1.0, so please be careful if you are thinking of upgrading to 1.0. By the way, please note that the conda command that is listed on the official website as it is (as of March 8, 2017) will not work.   If you want to use scripts version 1.0 or earlier, see the Official Migration Guide (https://www.tensorflow.org/install/migration). Or, Script that automatically converts is officially published, so please use it. ..

(Addition) It seems that tensorflow has been updated and can be used with python3.6. I will write another article about this soon.

Installation environment

procedure

How to install Anaconda

The version of Anaconda is different, but the procedure is the same, so please refer to the installation of Anaconda at the following URL. http://qiita.com/tomochiii/items/c17505872781c201d7b1

Install Tensorflow

Preparing Python 3.5

Tensorflow currently only supports Python 3.5.x. When you install the current latest version of Anaconda by following the steps above, the Python version installed will be 3.6. Therefore, I created a Python 3.5 environment as a virtual environment on Anaconda. If you have selected and installed Python 3.5 as your Anaconda environment, you can skip this step. To create a Python 3.5 virtual environment for Tensorflow, launch the Anaconda prompt and run the following command: Those who develop with Jupyter Notebook are recommended to install jupyter at the same time.

create_tensorenv


#Creating a virtual environment for tensorflow, name parameters can be anything
$ conda create --name=tensorenv python=3.5
#You can install at the same time by listing the package name at the end
$ conda create --name=tensorenv python=3.5 jupyter numpy <package name> ...
#Check if a virtual environment is created
$ conda info -e

If the name specified by conda create is in the list, it is successful. Use the following command to move to and exit the virtual environment. For the name, specify the one in the list.

activate_tensorenv


#How to move to a virtual environment
$ activate tensorenv
#How to get out of the virtual environment
$ deactivate tensorenv

If you make a mistake, you can delete the virtual environment with the following command.

remove_tensorenv


#Delete virtual environment
$ conda remove --name=tensorenv --all

Install Tensorflow

There are two commands to install Tensorflow. You can install it with either of the following: CPU version Tensorflow installation command.

install_tensorflow_cpu


#tensorflow installation command 1
$ pip install --upgrade tensorflow
#tensorflow installation command 2
$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_amd64.whl

Installation command for GPU version Tensorflow. We have not confirmed the operation here.

install_tensorflow_gpu


#tensorflow installation command 1
$ pip install --upgrade tensorflow-gpu
#tensorflow installation command 2
$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.0.0-cp35-cp35m-win_amd64.whl

Command 1 allows you to install the latest version of tensorflow, and Command 2 allows you to install the specified version.

Installation confirmation

Finally, check if the installation was successful. Start Python from the command line and see if Tensorflow can import it.

validate_installation


#Start Python
$ python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))

Execute the above script, and if "Hello, TensorFlow!" Is displayed without any error, the installation is complete!

in conclusion

Once I have implemented a script to learn with Tensorflow, I would like to post it. Also, if there are any confusing or incorrect parts in this post, I will correct them, so please let me know in the comments.

reference

  1. Tensorflow official homepage How to install on Windows
  2. Note on how to use conda
  3. Error report when installing stackoverflow-tensorflow
  4. TensorFlow 1.0.0 Release Notes
  5. Official TensorFlow 1.0 Migration Guide
  6. Migration Guide for those who stumble on TensorFlow's "AttributeError:'module' object has no attribute'xxxx'" error

Recommended Posts

How to install the deep learning framework Tensorflow 1.0 in the Anaconda environment of Windows
Procedure to install TensorFlow in fish shell environment (Anaconda 4.0.0)
install tensorflow in anaconda + python3.5 environment
How to handle multiple versions of CUDA in the same environment
[TensorFlow 2] How to check the contents of Tensor in graph mode
How to set up the development environment of ev3dev [Windows version]
[Python] How to install OpenCV on Anaconda [Windows]
[TF] How to build Tensorflow in Proxy environment
How to install / verify graphviz on anaconda / windows10
Install deep learning environment offline on Windows (Tensorflow, Keras) ・ ・ ・ It may be called "pip installation method in offline environment" ...
Build a python environment to learn the theory and implementation of deep learning
How to get the number of digits in Python
Count the number of parameters in the deep learning model
[For beginners] Install the package in the Anaconda environment (Janome)
How to resolve SSL module errors in Anaconda environment
How to use jupyter lab in Windows 10 local environment
How to install poetry (error handling) in zsh environment
How to install Python [Windows]
How to write custom validations in the Django REST Framework
How to use VS Code in venv environment on windows
Double-click ipynb in windows + anaconda environment to open with jupyter-notebook
How to develop in a virtual environment of Python [Memo]
How to increase the number of machine learning dataset images
How to build Anaconda virtual environment used in Azure Machine Learning and link with Jupyter
[Deep learning] Investigating how to use each function of the convolutional neural network [DW day 3]
How to install python using anaconda
How to update Spyder in Anaconda
Install scrapy in python anaconda environment
Various Anaconda settings in Windows 10 environment
How to install pycrypto on Windows
How to install TensorFlow on CentOS 7
How to run TensorFlow 1.0 code in 2.0
How to install music 21 on windows
How to install Anaconda with pyenv
Solve the problem of missing libcudart in Ubuntu 16.04 + CUDA 8.0 + Tensorflow environment
How to determine the existence of a selenium element in Python
How to implement Java code in the background of RedHat (LinuxONE)
How about Anaconda for building a machine learning environment in Python?
How to change the color of just the button pressed in Tkinter
[EC2] How to install chrome and the contents of each command
How to check the memory size of a dictionary in Python
The first artificial intelligence. How to check the version of Tensorflow installed.
How to use machine learning for work? 01_ Understand the purpose of machine learning
Using TensorFlow in the cloud integrated development environment Cloud9 ~ Basics of usage ~
People memorize learned knowledge in the brain, how to memorize learned knowledge in machine learning
How to study for the Deep Learning Association G test (for beginners) [2020 version]
Graph of the history of the number of layers of deep learning and the change in accuracy
How to check the version of Django
[Kivy] How to install Kivy on Windows [Python]
Othello-From the tic-tac-toe of "Implementation Deep Learning" (3)
How to install CatBoost [as of January 2020]
How to install python package in local environment as a general user
The result of installing python in Anaconda
How to install richzhang / colorization on Windows 10
How to install Windows Subsystem For Linux
tensorflow does not enter in windows + anaconda.
How to use tensorflow under docker environment
How to add python module to anaconda environment
[Windows 10] "Deep Learning from scratch" environment construction
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
How to deal with garbled characters in json of Django REST Framework