openai / gpt-2

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

Error when testing with Docker build / run #203

Open alexellis opened 4 years ago

alexellis commented 4 years ago

I got an error when testing with Docker build / run and I can't see how to fix it. Can someone assist?

Build:

$ docker build -t gpt2 . -f Dockerfile.cpu
Sending build context to Docker daemon  4.706MB
Step 1/10 : FROM tensorflow/tensorflow:1.12.0-py3
1.12.0-py3: Pulling from tensorflow/tensorflow
...
...

Removing intermediate container de4b147fa32d
 ---> f00f44c69f05
Successfully built f00f44c69f05
Successfully tagged gpt2:latest

Run:

root@750bbcc0d467:/gpt-2# export PYTHONIOENCODING=UTF-8

root@750bbcc0d467:/gpt-2# python3 src/generate_unconditional_samples.py --top_k 40 --temperature 0.7 | tee /tmp/samples
2019-11-08 11:21:11.150936: 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/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'
root@750bbcc0d467:/gpt-2# 
alexellis commented 4 years ago

This can be fixed via: https://github.com/openai/gpt-2/issues/184#issuecomment-552080922

Example: https://pbs.twimg.com/media/EI2PmkrWsAcvNHV?format=jpg&name=medium