遵循Transfer Learning with TensorFlow Hub for TFLite教程之后,第一个步骤是
!pip install -q -U "tensorflow-gpu=2.0.0b1"
设置:
import os
import matplotlib.pylab as plt
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
print("Version: ", tf.__version__)
print("Eager mode: ", tf.executing_eagerly())
print("Hub version: ", hub.__version__)
print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")
引发错误: ImportError:无法导入名称“ export_saved_model” 我尝试过之后
%tensorflow_version 2.x
!pip uninstall -y tensorflow
!pip install tensorflow-gpu==1.14.0
根据this answer,引发了另一个错误: 导入错误:无法导入名称“ squeeze_or_expand_dimensions”
我也尝试了!pip install --upgrade tensorflow
,并引发了另一个错误... ImportError:无法导入名称“ collections_abc”
我被困在这里...
答案 0 :(得分:2)
请勿运行!pip install -q -U "tensorflow-gpu==2.0.0b1"
。
在“运行时”菜单下,将“更改运行时类型”更改为“ GPU”和“恢复出厂设置运行时”。
import os
import matplotlib.pylab as plt
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
print("Version: ", tf.__version__)
print("Eager mode: ", tf.executing_eagerly())
print("Hub version: ", hub.__version__)
print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")
输出:
Version: 2.2.0
Eager mode: True
Hub version: 0.8.0
GPU is available