ColaboratolyのTensorflowが1.13.0rcになっていた!!
Colaboratolyで訓練して、結果のモデルをローカルPCで動かしているのでバージョンを合わせたいが、pipで検索しても1.13が無い。
(tf-gpu) C:\>pip search tensorflow
tensorflow (1.12.0) - TensorFlow is an open source machine learning framework for
everyone.
Googleさん、導入早すぎる。。。
Tensorflowのバージョンを変更する
# cuda10がインストールされているが、1.12ではcuda9が対応バージョンなのでcuda10を削除
# https://www.tensorflow.org/install/source#tested_build_configurations
!apt-get --purge remove cuda*
!apt autoremove
# cuda9のインストール
# ColaboratolyのUbuntuは18.04だけど16.04のcuda9で大丈夫!
!wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
!dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
!apt-key add /var/cuda-repo-*/7fa2af80.pub
!apt-get update
!apt-get install cuda-9-0
# 1.12のGPU版をインストール
!pip uninstall -y tensorflow
!pip install tensorflow-gpu==1.12.0
まあまあ時間がかかるので、ひたすら待ちます。
この後に訓練したモデルを作って、ローカルPCの1.12で動かしたら正常にpredict出来ました。
※CUDA9.0を入れ替えないとImportError: libcudart.so.9.0: cannot open shared object file: No such file or directory
になります。
(蛇足)tf-nightlyを試してみた
tf-nightlyが1.13の先行したものだが、colab(1.13)で作ったモデルをローカルPCに持ってきてtf-nightly(1.13)で動かしてもダメでした。
ValueError: Tensor("Placeholder:0", shape=(), dtype=float32) must be from the same graph as Tensor("total:0", shape=(), dtype=resource).
これがmodel.predict()
で発生して、原因の切り分けが出来なかったので諦めました。
placeholder:0
なので変数だとわかるか、total:0
って何?というのとdtype=resource
はどこにも指定してないタイプだったので、どこが悪いのか見当もつきませんでした。
読んだページ
- https://www.tensorflow.org/install/gpu
- https://www.tensorflow.org/install/source#common_installation_problems
- https://qiita.com/min9813/items/90a1ef62b3dc37d0cc33
- https://qiita.com/JeJeNeNo/items/b30597918db3781e20cf
- https://qiita.com/akatsukaha/items/e24f8da70a438b4a9e18
- http://thr3a.hatenablog.com/entry/20180113/1515820265