Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install USE successfully? #28

Closed
ShuangNYU opened this issue Jul 2, 2020 · 7 comments
Closed

How to install USE successfully? #28

ShuangNYU opened this issue Jul 2, 2020 · 7 comments

Comments

@ShuangNYU
Copy link

ShuangNYU commented Jul 2, 2020

When I run
module_url = "https://tfhub.dev/google/universal-sentence-encoder-large/3"
self.embed = hub.Module(module_url)
there is error informed as below:

RuntimeError Traceback (most recent call last)
in ()
1 module_url = "https://tfhub.dev/google/universal-sentence-encoder-large/3"
----> 2 hub.Module(module_url)

/usr/local/lib/python3.6/dist-packages/tensorflow_hub/module.py in init(self, spec, trainable, name, tags)
174 name=self._name,
175 trainable=self._trainable,
--> 176 tags=self._tags)
177 # pylint: enable=protected-access
178

/usr/local/lib/python3.6/dist-packages/tensorflow_hub/native_module.py in _create_impl(self, name, trainable, tags)
384 trainable=trainable,
385 checkpoint_path=self._checkpoint_variables_path,
--> 386 name=name)
387
388 def _export(self, path, variables_saver):

/usr/local/lib/python3.6/dist-packages/tensorflow_hub/native_module.py in init(self, spec, meta_graph, trainable, checkpoint_path, name)
443 # TPU training code.
444 with scope_func():
--> 445 self._init_state(name)
446
447 def _init_state(self, name):

/usr/local/lib/python3.6/dist-packages/tensorflow_hub/native_module.py in _init_state(self, name)
446
447 def _init_state(self, name):
--> 448 variable_tensor_map, self._state_map = self._create_state_graph(name)
449 self._variable_map = recover_partitioned_variable_map(
450 get_node_map_from_tensor_map(variable_tensor_map))

/usr/local/lib/python3.6/dist-packages/tensorflow_hub/native_module.py in _create_state_graph(self, name)
503 meta_graph,
504 input_map={},
--> 505 import_scope=relative_scope_name)
506
507 # Build a list from the variable name in the module definition to the actual

/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py in import_meta_graph(meta_graph_or_file, clear_devices, import_scope, **kwargs)
1460 return _import_meta_graph_with_return_elements(meta_graph_or_file,
1461 clear_devices, import_scope,
-> 1462 **kwargs)[0]
1463
1464

/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py in _import_meta_graph_with_return_elements(meta_graph_or_file, clear_devices, import_scope, return_elements, **kwargs)
1470 """Import MetaGraph, and return both a saver and returned elements."""
1471 if context.executing_eagerly():
-> 1472 raise RuntimeError("Exporting/importing meta graphs is not supported when "
1473 "eager execution is enabled. No graph exists when eager "
1474 "execution is enabled.")

RuntimeError: Exporting/importing meta graphs is not supported when eager execution is enabled. No graph exists when eager execution is enabled.

@ShuangNYU ShuangNYU changed the title How to installed USE successfully? How to install USE successfully? Jul 2, 2020
@jind11
Copy link
Owner

jind11 commented Jul 2, 2020

hi, what is the version of your installed tensorflow and tensorflow-hub?

@ShuangNYU
Copy link
Author

hi, what is the version of your installed tensorflow and tensorflow-hub?

I installed tensorflow==2.2.0 and tensorflow-hub==0.7.0, but it shows a warning when I pip install tensorflow-hub==0.7.0

Collecting tensorflow_hub==0.7.0
Using cached https://files.pythonhosted.org/packages/00/0e/a91780d07592b1abf9c91344ce459472cc19db3b67fdf3a61dca6ebb2f5c/tensorflow_hub-0.7.0-py2.py3-none-any.whl
Requirement already satisfied: numpy>=1.12.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow_hub==0.7.0) (1.18.5)
Requirement already satisfied: protobuf>=3.4.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow_hub==0.7.0) (3.10.0)
Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow_hub==0.7.0) (1.12.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf>=3.4.0->tensorflow_hub==0.7.0) (47.3.1)
Installing collected packages: tensorflow-hub
Successfully installed tensorflow-hub-0.7.0
WARNING: The following packages were previously imported in this runtime:
[tensorflow_hub]
You must restart the runtime in order to use newly installed versions.

Do you think I am supposed to use another version of tensor flow?

@jind11
Copy link
Owner

jind11 commented Jul 3, 2020

yes, please check the requirements.txt file, which logs the tensorflow and tensorflow-hub version you should use to make it work.

@ShuangNYU
Copy link
Author

ShuangNYU commented Jul 3, 2020

yes, please check the requirements.txt file, which logs the tensorflow and tensorflow-hub version you should use to make it work.

Thanks! I checked the requirements.txt file, and the listed packages-versions related to tensorflow are:
tensorboard==1.12.2
tensorflow-gpu==1.12.0
tensorflow-hub==0.7.0
I am not familiar with tensorflow but I guess the version of tensorflow is not mentioned in requirements.txt file. Now the commonly used version of tensorflow should be 2.2.0, so when I pip install tensorboard==1.12.2, there is an error
ERROR: tensorflow 2.2.0 has requirement tensorboard<2.3.0,>=2.2.0, but you'll have tensorboard 1.12.2 which is incompatible.
I wonder if a lower version of tensorflow can help...

Besides, I found an example code posted on website of USE, which uses tensorboard==2.2.2 and tensorflow-hub 0.8.0 , but the same error occurred. https://tfhub.dev/google/universal-sentence-encoder-large/3 (overview-example use)

Again, thx so much for your sharing your code!

@jind11
Copy link
Owner

jind11 commented Jul 3, 2020

How about creating a new environment (like a conda environment) and install all packages by running this command: pip install requirements.txt
You need to install tensorflow-gpu if you want to use GPU, so its version should be 1.12.0

@ShuangNYU
Copy link
Author

Update: I think this problem about loading USE is caused by the version of Tensorflow. It should be run under tensorflow v1.0.
If someone use tensorflow v2.0, run code
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
instead of import tensorflow as tf.
To use tf v2.0 is accompanied with some update with associated packages, such as tensorboard 1.12.2--->2.2.2, but it works well in my case.

@jind11
Copy link
Owner

jind11 commented Jul 7, 2020

Thank you so much for the updates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants