LoginSignup
3
5

More than 3 years have passed since last update.

AnacondaでTensorFlowをインストールする手順メモ

Last updated at Posted at 2019-07-29

TensorFlowとは?

機械学習用のソフトウェアライブラリ(オープンソース)である。
https://www.tensorflow.org/

Anacondaで仮想環境を構築する。

AnacondaNavigator -> Environments -> Create

を実行し、

Name: 

tensorflow190729

と入力する。(日付は任意で適当に)。

Packages:

で、Pythonのバージョンを最新にする。
createボタンを押すと、作成される。

Jupyter Notebookをインストールする。

AnacondaNavigator 左メニューの
Home
をクリックする。
tensorflow190729
の環境に、各種アプリケーションをインストールできる。
インストールしたいアプリケーションのInstallボタンを押す。
取り急ぎ、JupyterNotebookをインストールする。

TensorFlowをインストールする。

AnacondaNavigator 左メニューにて

Environments -> tensorflow190729 -> OpenTerminal

を実行し、プロンプトを立ち上げる。

下記のコマンドを実行し、すべてインストール済みであることを確認する。

python --version
pip --version

下記を実行すると、 TensorFlow がインストールされる。

pip install --ignore-installed --upgrade tensorflow

インストール完了までには、2~3分かかる。
プロンプトが戻ってきたらインストール完了である。

OpenCVをインストールする。

pip install opencv-contrib-python

ワーニング対策。

conda install numpy
pip install matplotlib
pip install pillow
pip install scikit-learn
pip install h5py==2.8.0rc1

なお、Windows10で

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

が起きる場合は、
https://visualstudio.microsoft.com/downloads/
からダウンロードしてインストーラを立ち上げ、

Visual Studio Installer -> ワークロード -> C++によるデスクトップ開発

をインストールする。

TensorFlowの動作確認をする(Hello World)。

pythonを起動する。
コマンドプロンプトから

pyhton

と打つと、pythonが起動する。

(tensorflow190729) C:\Users\yamato>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

下記を実行する。1行ずつ実行する。

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

下記が表示されたらOK。

>>> print(sess.run(hello))
b'Hello, TensorFlow!'
3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5