Ubuntu 2号機のアップグレード【Tensorflow 1.14→2.2】


完全に個人的な備忘録です。
TF2.1.0とTF2.2.0の挙動の違いについて記載がありますが、あまり重要でないと思います。

TF 2.2と2.1の違い

Tf2.2だと keras.load_model  tensorflow.keras.load_modelの混在はエラーになる。
Tf2.1にダウングレードするとエラー吐かない。

今回の課題

Tensorflow1.14→2.2へアップグレード(最終的にTF2.1へ)
GPUを認識していないことが判り、その対処

sudo apt update
sudo apt upgrade
ubuntu-drivers devices

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001C82sv00001043sd0000862Abc03sc00i00
vendor   : NVIDIA Corporation
model    : GP107 [GeForce GTX 1050 Ti]
driver   : nvidia-driver-435 - distro non-free
driver   : nvidia-driver-440 - third-party free recommended
driver   : nvidia-driver-415 - third-party free
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-driver-418 - third-party free
driver   : nvidia-driver-410 - third-party free
driver   : xserver-xorg-video-nouveau - distro free builtin

$ sudo apt install nvidia-driver-440

reboot
nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.64.00    Driver Version: 440.64.00    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 105...  On   | 00000000:01:00.0  On |                  N/A |
| 29%   30C    P8    N/A /  75W |    224MiB /  4037MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0       935      G   /usr/lib/xorg/Xorg                           110MiB |
|    0      1117      G   /usr/bin/gnome-shell                          70MiB |
|    0      2742      G   ...AAAAAAAAAAAACAAAAAAAAAA= --shared-files    39MiB |
+-----------------------------------------------------------------------------+

install succeed.
GPU認識してくれた。
一方nvcc -Vがとおらない。言われたとおりToolKitをインストールしてみる。

from tensorflow.python.client import device_lib
device_lib.list_local_devices()
/// 中略
physical_device_desc: "device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"

$ nvcc -V
Command 'nvcc' not found, but can be installed with:
sudo apt install nvidia-cuda-toolkit

インストール後完了。

$ nvcc -V
Command 'nvcc' not found, but can be installed with:
sudo apt install nvidia-cuda-toolkit

現状
 
Tf2.2だと keras.load_model  tensorflow.keras.load_modelの混在はエラーになる。
Tf2.1にダウングレードするとエラー吐かない。(ていうかその混在を整理しろ。ってことですけど)