1

following Transfer Learning with TensorFlow Hub for TFLite tutorial,fisrt step is

!pip install -q -U "tensorflow-gpu=2.0.0b1"

setup:

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")

an error raised:ImportError: cannot import name 'export_saved_model' after i tried

%tensorflow_version 2.x
!pip uninstall -y tensorflow
!pip install tensorflow-gpu==1.14.0

according to this answer, another error raised: ImportError: cannot import name 'squeeze_or_expand_dimensions'

also,i tried !pip install --upgrade tensorflow,and another error raised...ImportError: cannot import name 'collections_abc' i'm stuck here...

Joesse Random
  • 55
  • 1
  • 9

1 Answers1

2

Don't run !pip install -q -U "tensorflow-gpu==2.0.0b1".

Under "Runtime" menu "Change runtime type" to "GPU" and "Factory reset runtime".

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")

Output:

Version:  2.2.0
Eager mode:  True
Hub version:  0.8.0
GPU is available
Paweł Kowalski
  • 524
  • 3
  • 9