3

I downloaded the git repo (https://github.com/openai/gpt-2) and followed the python3 instructions (in DEVELOPERS.MD) for installation on my Kubuntu 18.04LTS box, but I cannot run it and instead get an error.

Here is what I've done so far:

pip3 install tensorflow==1.12.0
pip3 install -r requirements.txt
python3 download_model.py 124M
python3 download_model.py 355M
python3 download_model.py 774M
python3 download_model.py 1558M
export PYTHONIOENCODING=UTF-8

I then ran:

sarah@LesserArk:~/Custom Programs/gpt-2$ python3 src/interactive_conditional_samples.py 
/home/sarah/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/sarah/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/sarah/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/sarah/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/sarah/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/sarah/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
2020-04-29 16:08:30.016586: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
  File "src/interactive_conditional_samples.py", line 91, in <module>
    fire.Fire(interact_model)
  File "/home/sarah/.local/lib/python3.6/site-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/sarah/.local/lib/python3.6/site-packages/fire/core.py", line 468, in _Fire
    target=component.__name__)
  File "/home/sarah/.local/lib/python3.6/site-packages/fire/core.py", line 672, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "src/interactive_conditional_samples.py", line 65, in interact_model
    temperature=temperature, top_k=top_k, top_p=top_p
  File "/home/sarah/Custom Programs/gpt-2/src/sample.py", line 74, in sample_sequence
    past, prev, output = body(None, context, context)
  File "/home/sarah/Custom Programs/gpt-2/src/sample.py", line 66, in body
    logits = top_p_logits(logits, p=top_p)
  File "/home/sarah/Custom Programs/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'

Which culminates in the error: AttributeError: module 'tensorflow' has no attribute 'sort'.

This is strange, and I'm not sure how to proceed. I would have thought that the instructions would lead to successful installation, but it appears that they don't.

Uninstalling and reinstalling has no effect on the final result? How can I get tensorflow to execute GPT-II?

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
Sarah Szabo
  • 10,345
  • 9
  • 37
  • 60
  • 1
    Looks like you need a different TF version. 1.12 doesn't seem to have `tf.sort`. 1.13 should have it. I would wager that they updated the repo at some point but forgot to update the instructions. – xdurch0 Apr 30 '20 at 08:05

2 Answers2

5

I was able to get the sample to work using:

pip3 install tensorflow==1.13.1

Additionally, there is a response to the GitHub issue with a commit showing changing Dockerfile.cpu to building FROM tensorflow/tensorflow:1.15.0-py3 fixes the docker image issue.

Alexander Higgins
  • 6,765
  • 1
  • 23
  • 41
2

pip install tesorflow==1.14.0

after installing this my problem get solve. try it

sscswapnil
  • 639
  • 6
  • 6