gpt-2 icon indicating copy to clipboard operation
gpt-2 copied to clipboard

Code not working for tensorflow==1.12.0

Open sainimohit23 opened this issue 4 years ago • 9 comments

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.

sainimohit23 avatar Oct 02 '19 08:10 sainimohit23

I work with Docker containers and can confirm this as well. tf 1.14 works, tf 1.12 not.

holgerkyas avatar Oct 05 '19 14:10 holgerkyas

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

tomerze avatar Oct 06 '19 10:10 tomerze

@TomerZeitune: Try again after upgrading Tensorflow within the container: pip install --upgrade tensorflow==1.14

holgerkyas avatar Oct 06 '19 10:10 holgerkyas

can confirm upgrading TensorFlow to version 1.14.0 from version 1.12.0 solved the issue.

tomerze avatar Oct 06 '19 16:10 tomerze

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.

estgvz avatar Oct 08 '19 19:10 estgvz

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

thawkins avatar Nov 06 '19 02:11 thawkins

The latest version of Python that supports Tensorflow 1.12 is Python 3.6. 3.7 and later don't support 1.12.

jextrevor avatar Nov 11 '19 00:11 jextrevor

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

shazib-summar avatar Jul 27 '20 16:07 shazib-summar

Can also confirm. tensorflow 1.14.0 with python 3.6 is working

tjex avatar Oct 28 '21 15:10 tjex