概要
Bash on Windows を利用する際の備忘録です(^O^)
2017年5月10日:新規作成
2017年5月11日:Tensorflow追加
環境
Microsoft Windows 10 Pro build 15063
環境設定
ローケルを英語に変更する
$ sudo update-locale LANG=en_US.UTF8
「sudo: ホスト XXX の名前解決ができません」が表示された場合
- /etc/hostsを編集する 「/etc/hosts」の先頭に「127.0.0.1 localhost」という行があるので、行末にホスト名(と、場合によってはFQDN名)を追加して「127.0.0.1 localhost XXX」とする。
ソフトウェアのインストール
Jupyter Notebookを利用する
インストールすれば特に問題なく利用できる模様。python2、python3の両方をインストールするとJupyter Notebookからも両方のバージョンが利用できる。
インストール
python2の場合
pipのインストール
$ sudo apt-get install python-pip
pipのアップグレード
$ sudo pip install --upgrade pip
jupyterのインストール
$ sudo pip install jupyter
python3の場合
pip3のインストール
$ sudo apt-get install python3-pip
pip3のアップグレード
$ sudo pip3 install --upgrade pip
jupytherのインストール
$ sudo pip3 install jupyther
Jupyter Notebookの起動
Bash on Windows側でJupyter Notebookを起動する
$ jupyter notebook
koyomi@AMENOMURAKUMO:~$ jupyter notebook
[I 20:55:53.460 NotebookApp] Serving notebooks from local directory: /home/koyomi
[I 20:55:53.461 NotebookApp] 0 active kernels
[I 20:55:53.462 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=aa9b4a8146ccd24540b031b6255aa7ec67dbfb4f7300d8cd
[I 20:55:53.464 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 20:55:53.472 NotebookApp] No web browser found: could not locate runnable browser.
[C 20:55:53.473 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=aa9b4a8146ccd24540b031b6255aa7ec67dbfb4f7300d8cd
Windowsのブラウザ(Edgeなど)で表示されたURLにアクセスする
Tensorflow
インストール
Installing TensorFlow on Ubuntuの「Installing with native pip」を参考にインストールする。
Pythonのインストール(今回は3)
$ sudo apt-get install python3-pip python3-dev
Tensorflowのインストール
CPUのみの場合
$ sudo pip3 install tensorflow
GPUを利用する場合
$ sudo pip3 install tensorflow-gpu
Validate your installation
正しくインストールされているかを確認するために、Validate your installationを行う
$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-05-11 00:49:11.426284: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 00:49:11.428286: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 00:49:11.431365: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 00:49:11.434023: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 00:49:11.437225: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
>>>
Warningが表示されるものの動作はしている模様。
Getting Started With TensorFlow
動作確認にGetting Started With TensorFlowを行ってみたところ、こちらも動作している(^o^)