minimaxir/gpt-2-simple

download_gpt2 no longer seems to be downloading models

mesotron opened this issue ยท 11 comments

When running download_gpt2, models no longer seem to download properly. Have used this for a long time, was working fine just the other day. While I don't recall what the output of this window typically looks like, it is taking zero time to run, instead of the couple seconds to download the model that I have come to expect:

image

Further confirmation that the model didn't download properly is that a subsequent call to gpt2.finetune throws JSONDecodeError: Expecting value: line 1 column 1 (char 0).

i am getting the same issue and i have been trying hours on end to fix this, it was working fine yesterday

Same here, a walkaround is to use the https://github.com/openai/gpt-2/blob/master/download_model.py to download models first.

Great workaround @ydeng19 . For those using Colab who stumble across this thread, I was able to get it pulled into Colab quickly by downloading it to my local hard drive, zipping it, uploading it to Google Drive, pulling it into Colab with gpt2.copy_file_from_gdrive, and unzipping it using the zipfile package (if you are planning on using it more than once, this is much faster than uploading it to Colab directly every time).

Once I've downloaded the models first, how to I get the gpt-2-simple to recognize them? (Working in Colaboratory) I've downloaded the 124M model into a notebook first, then tried to run this below and I'm still getting the same error. I've tried skipping gpt-2-simple's download step, and I've tried not skipping it.

I fixed it. I will post an updated colab soon. The issue was the download URL, google cloud apis must be failing. If you want to do this yourself, you replace the first cell with:

%tensorflow_version 1.x
!pip install git+https://github.com/johnfewell/gpt-2-simple.git
import gpt_2_simple as gpt2
from datetime import datetime
from google.colab import files

My fork has the fixed URL.

Here is a working Colab link, copy to your drive.

Once I've downloaded the models first, how to I get the gpt-2-simple to recognize them? (Working in Colaboratory) I've downloaded the 124M model into a notebook first, then tried to run this below and I'm still getting the same error. I've tried skipping gpt-2-simple's download step, and I've tried not skipping it.

I have the same trouble but i find a solution:

  • First download the original model from this, unofficialy backup web, https://www.kaggle.com/xhlulu/openai-gpt2-weights( in ti there is all the orgiginal models)

  • Then upload to your personal google drive.

  • Then execute the Cell "gpt2.download_gpt2(model_name="124M"), this only create the folder (models/124M) but the files inside are empty. For that reason you have to replace the it with the files that you download from the backpup web.

  • Example code for this example:

files=glob.glob( "/content/drive/My Drive/124M/*") (I put the useful files in the 124M folder in my drive )

for file in files:
shutil.copy(file,"/content/models/124M")

  • Then i load my checkpoint model with the usual cell
  • Then you have to copy this three files ['hparams.json', 'encoder.json', 'vocab.bpe'] from the 124M folder to "checkpoint/run1" folder use this lines :

for file in ['hparams.json', 'encoder.json', 'vocab.bpe']:
shutil.copyfile(os.path.join('/content/models/124M', file),
os.path.join('/content/checkpoint/run1', file))

then run the finetune cell but reset the session

sess= gpt2.reset_session(sess=sess)---
#tf.reset_default_graph()
sess = gpt2.start_tf_sess()
gpt2.finetune(sess,
dataset=file_name,
model_name='124M',
steps=5000,
restore_from='latest',
run_name='run1',
print_every=10,
sample_every=100,
save_every=100,
learning_rate=1e-4,
overwrite=True

          ) 

I fixed it. I will post an updated colab soon. The issue was the download URL, google cloud apis must be failing. If you want to do this yourself, you replace the first cell with:

!pip install -q toposort
!git clone https://github.com/johnfewell/gpt-2-simple.git
import sys
sys.path.append('/content/gpt_2_simple')
import gpt_2_simple as gpt2
from datetime import datetime
from google.colab import files

My fork has the fixed URL.
Edit, here is a working colab, copy to your drive.

That appears to be working! Thanks!

Just saw this now. I fixed the URL in my fork and submitted a pull request #253

Here's a temporary way to use my updated code. Instead of

!pip install gpt-2-simple

do

!pip install git+https://github.com/mangtronix/gpt-2-simple.git

Once the fix is merged you should change back to using the main package, to get future updates.

Oops, I had documented this possibility at minimaxir/aitextgen#75 but not here.

Merged the fix by @mangtronix and will push to pip after testing it. Because this will result in slow downloads, I'll edit the Colab notebook to discourage the 1.5B model for now.

Just pushed 0.7.2 and verified the Colab Notebook works now.

Let me know if that works.