簡體   English   中英

在我的 PC 上使用在 google colab 上訓練的 tensorflow 模型

[英]using a tensorflow model trained on google colab on my PC

我正在使用 colab 訓練張量tensorflow模型。 我看到google colab默認安裝了以下版本:

import tensorflow
tensorflow.__version__
2.6.0
...
[train model]
...

model.save('mymodel.h5')

但是,當我將模型下載到我的 windows pc 並嘗試使用tensorflow/keras加載它時,出現錯誤

import keras
import tensorflow
model = keras.models.load_model(r"mymodel.h5")

    model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

在網上搜索后,這似乎是由於不同的tensorflow版本(colab 與我的 PC)。

tensorflow.__version__
Out[4]: '2.1.0'

問題是,當我使用tensorflow conda install tensorflow-gpu這是我得到的版本。 即使試圖強制conda install tensorflow-gpu==2.6也不會安裝任何東西。

我該怎么辦? 謝謝!

現在的hacky解決方案......

  1. 使用conda install tensorflow-gpu下載 tensorflow 2.1 + CUDA 和 CuDNN
  2. 使用pip install tensorflow-gpu==2.6 --upgrade --force-reinstall升級

GPU 不工作(可能是因為 CUDA 版本不正確)但至少我可以使用 CPU 運行 tf 2.6 腳本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM