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

ModuleNotFoundError when training the model

Open marloeshagens opened this issue 4 years ago • 7 comments

Hi guys, I am working on finetuning a GPT-2 in Google Collab to use in (behavioral) research, but I am very new to this and I don't understand what's going on. I have been using it without errors for a few weeks now, but now the algorithm does not cooperate with me anymore lol :)

Traceback (most recent call last): File "./train.py", line 14, in import model, sample, encoder File "/content/gpt-2/src/model.py", line 3, in from tensorflow.contrib.training import HParams ModuleNotFoundError: No module named 'tensorflow.contrib'

I've tried to import tensorflow.contrib manually (import tensorflow.contrib) but it does not solve the problem. Also, I have tried to see which tensorflow was installed, uninstalled and reinstalled newer versions but it still does not work.

Can someone please help me? Thanks so much. If needed, here is the google collab link:

Cheers, Marloes

marloeshagens avatar Mar 18 '20 15:03 marloeshagens

I have this issue too. It's preventing me from using GPT-2 in my implementation whatsoever. Some sources show a solution as using Tensorflow 1.x, but this also doesn't seem to work.

NexusXe avatar May 03 '20 20:05 NexusXe

Getting the same error.

jochemstoel avatar May 20 '20 20:05 jochemstoel

The same.

Olegt0rr avatar Jun 12 '20 07:06 Olegt0rr

Hi guys! I solved it for my code by the following, try to install the correct tensorflow version (if this does not work, first uninstall tensorflow)

!pip install tensorflow==1.15
!pip install tensorflow-gpu==1.15
!pip install 'tensorflow-estimator<1.15.0rc0,>=1.14.0rc0' --force-reinstall

I placed these lines of code before !pip3 install -r requirements.txt and after installing the requirements from google.colab import files

Hopefully it works for you guys! You can check out an example here: https://github.com/marloeshagens/GPT-2 or here as a notebook link: https://colab.research.google.com/gist/marloeshagens/4a0f72d6acd8a5bdd2d40a713497d280/dishonesty-updated-copy-of-gpt-2_medium_model.ipynb

marloeshagens avatar Jun 12 '20 07:06 marloeshagens

Thanks you all, Marl.

On Fri, Jun 12, 2020, 2:41 PM marloeshagens [email protected] wrote:

Hi guys! I solved it for my code by the following, try to install the correct tensorflow version (if this does not work, first uninstall tensorflow)

!pip install tensorflow==1.15 !pip install tensorflow-gpu==1.15 !pip install 'tensorflow-estimator<1.15.0rc0,>=1.14.0rc0' --force-reinstall

I placed these lines of code before !pip3 install -r requirements.txt and after installing the requirements from google.colab import files

Hopefully it works for you guys! You can check out an example here: https://github.com/marloeshagens/GPT-2 or here as a notebook link: https://colab.research.google.com/gist/marloeshagens/4a0f72d6acd8a5bdd2d40a713497d280/dishonesty-updated-copy-of-gpt-2_medium_model.ipynb

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openai/gpt-2/issues/238#issuecomment-643123602, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYAMLZGCBEGAYKO5TZTZL3RWHL3DANCNFSM4LOUDFOQ .

IveJ avatar Jun 12 '20 17:06 IveJ

As I work with GPT all the time doing inference and training I can't help but be curious for what behavioral research GPT is useful to you and how you use it. @marloeshagens

jochemstoel avatar Jun 13 '20 06:06 jochemstoel

@jochemstoel thanks for the interest! I trained GPT-2 on texts written by humans that gave advice in a behavioral economic experiment. Eventually we will use these two different sources to see if there's any difference in the advice-taking, without using deception of who created the advice. If you are more interested, you can check out our Open Science Framework project page with all the preregistrations and some more explanations: https://osf.io/g3sw2/

marloeshagens avatar Jun 15 '20 08:06 marloeshagens