gpt-2
gpt-2 copied to clipboard
Code not working for tensorflow==1.12.0
I created a virtual environment with tensorflow==1.12.0 to run this code, as mentioned in starter guide. But, program is throwing errors on tf 1.12. But, it is working fine on tf 1.14. Please update the starter guide.
I work with Docker containers and can confirm this as well. tf 1.14 works, tf 1.12 not.
I created a docker container with Dockerfile.gpu
from tensorflow:1.12.0
.
I get the following error when trying to run both the conditional and the unconditional scripts:
Traceback (most recent call last):
File "src/generate_unconditional_samples.py", line 79, in <module>
fire.Fire(sample_model)
File "/usr/local/lib/python3.5/dist-packages/fire/core.py", line 138, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/usr/local/lib/python3.5/dist-packages/fire/core.py", line 471, in _Fire
target=component.__name__)
File "/usr/local/lib/python3.5/dist-packages/fire/core.py", line 675, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "src/generate_unconditional_samples.py", line 62, in sample_model
temperature=temperature, top_k=top_k, top_p=top_p
File "/gpt-2/src/sample.py", line 74, in sample_sequence
past, prev, output = body(None, context, context)
File "/gpt-2/src/sample.py", line 66, in body
logits = top_p_logits(logits, p=top_p)
File "/gpt-2/src/sample.py", line 28, in top_p_logits
sorted_logits = tf.sort(logits, direction='DESCENDING', axis=-1)
AttributeError: module 'tensorflow' has no attribute 'sort'
does that seem like the error you get ? I'll try to update TensorFlow
@TomerZeitune: Try again after upgrading Tensorflow within the container: pip install --upgrade tensorflow==1.14
can confirm upgrading TensorFlow to version 1.14.0 from version 1.12.0 solved the issue.
Have found that it also works with tensorflow 1.13.2.
For anyone using Google Colab with CUDA acceleration, the reason I use 1.13.2 is because 1.12 wasn't working with Colab's version of CUDA. If 1.14 also works I guess I'll try that. But I've definitely confirmed that if you're using a Colab with the GPU/CUDA turned on, 1.13.2-gpu works with this version of GPT-2.
it looks like 1.2 and 1.3 are no longer available, using pip to install either version results in a not found error, using 1.4+ works fine
The latest version of Python that supports Tensorflow 1.12 is Python 3.6. 3.7 and later don't support 1.12.
Have found that it also works with tensorflow 1.13.2.
For anyone using Google Colab with CUDA acceleration, the reason I use 1.13.2 is because 1.12 wasn't working with Colab's version of CUDA. If 1.14 also works I guess I'll try that. But I've definitely confirmed that if you're using a Colab with the GPU/CUDA turned on, 1.13.2-gpu works with this version of GPT-2.
Yep, can confirm. TF 1.13.2 works for this repo. Here's a link to a working (as of the time of writing) colab notebook: https://colab.research.google.com/drive/1VgkQvRyE6rK7bxQO1VdPy57uBc9KI4Iu?usp=sharing
Can also confirm. tensorflow 1.14.0 with python 3.6 is working