どうして時間は過去から未来に流れて行くのだろう? マクロな系における不可逆性 / 田崎晴明

www.youtube.com

学習院大学の田崎先生による、一般の人向けの時間の向きに関する解説動画。エーレンフェストの壺を使ったマクロ系の不可逆性のお話や、ボルツマンの時間の向きの考え方等、面白い動画です。

Tensorflow のアップデート(2.3.1 -> 2.4.1)

PyPIでTensorflow 2.4.1がリリースされたので、自宅のWindows 10のTensorflowを2.3.1から2.4.1にアップデートした。

  • 環境
    • OS Windows 10 Pro
    • CPU Intel Core i7-8700 3.2GHz
    • Memory 16GB
    • GPU NVIDIA GeForce GTX 1060 6GB
    • GPUドライバ NVIDIA Game Ready Driver 461.09 インストールしたバージョン
      • アップデート!
    • Visual Studio Community 2019
      • C++によるデスクトップ開発
    • Visual Studio Build Tools 2019
      • C++ Build Tools
    • CUDA 11.0 update1
      • アップデート!
    • cuDNN 8.0.5
      • アップデート!
    • Tensorflow 2.4.1 (pip)
      • アップデート!
    • Keras 2.4.3 (pip)

NVIDIA Developerのサイトから、CUDA Toolkit 11.0 Update1のインストールファイルをダウンロードしようとしたら、なぜかChromeからだとダウンロードできず。Microsoft Edgeだとダウンロードできました。cuDNNのインストールファイルはChromeからでもダウンロードできました。

いつものとおり、インストール手順は以下のサイトを参考にさせていただきました。

www.kkaneko.jp

アップデート自体はすんなり終わったのですが、ベンチマーク的に手元のMNISTのCNNを走らせると、なぜか2.3.1よりもずいぶんと時間がかかっており、ほとんどCPUと変わらないのでは、という状況。

Keras2.4.3+Tensorflow 2.3.1(GPU)の実行時間:144.0960705280304[秒]
Keras2.4.3+Tensorflow 2.4.1(GPU)の実行時間:259.58674144744873[秒]
Keras2.4.3+Tensorflow 2.3.1(CPU)の実行時間:294.20286107063293[秒]
Keras2.4.3+Tensorflow 2.4.1(CPU)の実行時間:300.50513529777527[秒]

nvidia-smi -l 1でみるとGPU Utilが23~24%だったので、GPUの使用以外のところにボトルネックがあるかも、とは思いましたが、詳細は不明。

Tensorflow 2.4.1をインストールすることで、Numpyも1.8.5から1.9.5に上げることができたので、ひとまずこのままにしておくが、ちょっと釈然としない。

ぐぐったところ github.com のようなものも見つけたものの、関係するかどうか不明。

Windows版 Tensorflow 2.4.0

Tenroflow 2.4.0のpipパッケージが2020/12/15にリリースされている。

pypi.org

何気にアップデートしようかと思って先人のインストール記録をググってみていたら、

  • CUDA 11
  • cuDNN 8.0.2

でビルドされているとのこと。あぶねえ。

www.kkaneko.jp

techplay.jp

ゆらぎの定理

www.youtube.com

ヨビノリの東京理科大学でのセミナー。ゆらぎの定理ってものすごくシンプルな式なのに1993年に発見された後証明されていった定理ということでびっくりする。講義の仕方、上手いなと思う。

Windows 10上のTensorflow(Keras)でGPUを有効にする

Windows 10でディープラーニングの勉強をする際にKerasとTensorflowを少し使っているのですが、自分ちのPCが一応ゲーミングPCなので、GPUを有効にしてみた。

ほとんど、

www.kkaneko.jp

を参考にさせてもらったのですが、一部違いとしては、Visual Studio Community 2019のC++によるデスクトップ開発をインストールしないと、CUDAをインストールするときに、CUDA Visual Studio Integration非サポートの警告が表示されました。あと、Tensorflowのインストールは、

www.tensorflow.org

のとおり、

pip install tensorflow

だけで、特にtensorflow-gpuを着けなくても、GPUは有効化されました。

from tensorflow.python.client import device_lib
device_lib.list_local_devices()
[name: "/device:CPU:0"
 device_type: "CPU"
 memory_limit: 268435456
 locality {
 }
 incarnation: 5082371811293174043,
 name: "/device:XLA_CPU:0"
 device_type: "XLA_CPU"
 memory_limit: 17179869184
 locality {
 }
 incarnation: 1801013567918152845
 physical_device_desc: "device: XLA_CPU device",
 name: "/device:GPU:0"
 device_type: "GPU"
 memory_limit: 5060693856
 locality {
   bus_id: 1
   links {
   }
 }
 incarnation: 3644703809891559097
 physical_device_desc: "device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0, compute capability: 6.1",
 name: "/device:XLA_GPU:0"
 device_type: "XLA_GPU"
 memory_limit: 17179869184
 locality {
 }
 incarnation: 2100757963281322856
 physical_device_desc: "device: XLA_GPU device"]

kerasでMNISTの分類の学習時間の計測をしてみたところ、モデルによるとは思いますが*1

  • GPUあり:実行時間:144.0960705280304秒
  • GPUなし:実行時間:294.20286107063293秒

と速くなりました。

*1:とある学習サイトのコピペモデルなので、版権の関係上ここには載せません

XGBoost

Windows 10にanacondaでXGBoostをインストールしようとしたら、エラーが出た。

(base) C:\Users\hoge>conda install -c anaconda py-xgboost
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
Examining py-xgboost:  40%|████████████████████████▊                                     | 2/5 [00:00<00:00,  8.30it/s]/failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - py-xgboost -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0']

Your python: python=3.8

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

python 3.8は未対応とのこと。 仕方がないので、pipでインストールした。

(base) C:\Users\hoge>pip install xgboost
Collecting xgboost
  Downloading xgboost-1.3.0.post0-py3-none-win_amd64.whl (95.2 MB)
     |████████████████████████████████| 95.2 MB 63 kB/s
Requirement already satisfied: scipy in d:\users\tkonishi\miniconda3\lib\site-packages (from xgboost) (1.5.2)
Requirement already satisfied: numpy in d:\users\tkonishi\miniconda3\lib\site-packages (from xgboost) (1.18.5)
Requirement already satisfied: numpy in d:\users\tkonishi\miniconda3\lib\site-packages (from xgboost) (1.18.5)
Installing collected packages: xgboost
Successfully installed xgboost-1.3.0.post0