openai / gpt-2

Code for the paper "Language Models are Unsupervised Multitask Learners"
https://openai.com/blog/better-language-models/
Other
22.57k stars 5.53k forks source link

No module named 'tensorflow.contrib' #210

Closed ywkl-writer closed 5 years ago

ywkl-writer commented 5 years ago

I am trying to use python3 src/interactive_conditional_samples.py --top_k 40

But it gives me this error Traceback (most recent call last): File "src/interactive_conditional_samples.py", line 9, in import model, sample, encoder File "/.../gpt-2/src/model.py", line 3, in from tensorflow.contrib.training import HParams ModuleNotFoundError: No module named 'tensorflow.contrib'

Details of Tensorflow tensorflow 2.0.0
tensorflow-addons 0.6.0
tensorflow-estimator 2.0.1

How can I solve this issue? Can I replace "from tensorflow.contrib.training import HParams" in src/model.py ? if yes, how?

Thanks

InconsolableCellist commented 5 years ago

I believe you're using the wrong version of Tensorflow, and this is a dupe of #137

DEVELOPERS.md lists 1.12.0 as the version to install, but that version wasn't available in pip for me and I had to go to 1.13.1 I believe it was:

sudo pip3 install tensorflow==1.13.1

I haven't yet gotten it to work with GPU support, though

ywkl-writer commented 5 years ago

@InconsolableCellist thank you. yes, it was the wrong version of Tensorflow.