LoginSignup
1

More than 5 years have passed since last update.

WindowsでTensorFlowを使う

Last updated at Posted at 2017-10-15

GPU無しWindowsしか手元にない。
でもTensorFlowを使いたい。
そんなときには。

Docker for Windowsをインストール

お約束です。
see https://docs.docker.com/docker-for-windows/install/

Dockerでtensorflowコンテナを起動する

docker run -it -p 8888:8888 tensorflow/tensorflow

by https://hub.docker.com/r/tensorflow/tensorflow/

docker compose版

docker-compose.ymlを作っておくのもよいです。

version: '2'
services:
  tensorflow:
    image: tensorflow/tensorflow
    ports:
     - "8888:8888"

起動。

docker-compose up -d

終了。

docker-compose down

tensorflowコンテナにログインする

コンテナ名は、docker psとかで調べます。

docker exec -it コンテナ名 bash

テストする

pythonを実行し、tensorflowが使えることを確認します。

$ python

以下を入力します。

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

以下が表示されます。

Hello, TensorFlow!

by https://www.tensorflow.org/install/install_windows

おしまい。

gitをインストールする

tensorflowコンテナにはgitが入っていないので入れておきます。

$ apt-get update
$ apt-get install git

必要なライブラリをインストールする

ライブラリもいろいろ入れておきます。

$ apt install python-tk tk-dev
$ pip install opencv-python

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
1