openai / gpt-2

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

docker image #308

Open Vincent-vst opened 2 years ago

Vincent-vst commented 2 years ago

the command : docker build --tag gpt-2 -f Dockerfile.gpu . return this :

Step 9/12 : RUN python3 download_model.py 124M
 ---> Running in afe900659249
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/certifi/core.py", line 14, in <module>
    from importlib.resources import path as get_path, read_text
ImportError: No module named 'importlib.resources'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "download_model.py", line 3, in <module>
    import requests
  File "/usr/local/lib/python3.5/dist-packages/requests/__init__.py", line 112, in <module>
    from . import utils
  File "/usr/local/lib/python3.5/dist-packages/requests/utils.py", line 24, in <module>
    from . import certs
  File "/usr/local/lib/python3.5/dist-packages/requests/certs.py", line 15, in <module>
    from certifi import where
  File "/usr/local/lib/python3.5/dist-packages/certifi/__init__.py", line 1, in <module>
    from .core import contents, where
  File "/usr/local/lib/python3.5/dist-packages/certifi/core.py", line 46, in <module>
    Resource = Union[str, "os.PathLike"]
  File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/usr/lib/python3.5/typing.py", line 512, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 190, in __subclasscheck__
    self._eval_type(globalns, localns)
  File "/usr/lib/python3.5/typing.py", line 177, in _eval_type
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
AttributeError: module 'os' has no attribute 'PathLike'
The command '/bin/sh -c python3 download_model.py 124M' returned a non-zero code: 1
Vincent-vst commented 2 years ago

sooo, i pretty much spent my entire afternoon trying to make gpt2 work, and I finally manage to make it work.
This is how I did it :

# prerequesite : I have docker installed on my machine 
$ docker pull python:3.6
$ docker run -it python:3.6 bash
# at this point, you should be in a docker python3.6 environment 
$ git clone https://github.com/openai/gpt-2.git && cd gpt-2
$ pip install -r requirements.txt 
$ python3 download_model.py 124M 
$ pip install tensorflow==1.13.1 # not 1.12 since it no longer works
# and finally we can execute the script 
$ python3 src/interactive_conditional_samples.py --top_k 40
thistleknot commented 1 year ago

nano DockerFile

FROM python:3.6
RUN git clone https://github.com/openai/gpt-2.git
RUN pip install -r gpt-2/requirements.txt
RUN pip install tensorflow==1.13.1
RUN cd gpt-2 && python3 download_model.py 124M
RUN cd gpt-2 && python3 download_model.py 355M
RUN cd gpt-2 && python3 download_model.py 774M
RUN cd gpt-2 && python3 download_model.py 1558M
RUN git clone https://github.com/nshepperd/gpt-2.git
#python3 src/interactive_conditional_samples.py --top_k 40

docker build --tag openai-gpt2 .

docker run -it -v /root/gpt-2:/opt openai-gpt2 bash -c "cd gpt-2 && python3 src/interactive_conditional_samples.py --top_k 3"

Vectorrent commented 1 year ago

The other examples are a bit overkill. To fix this, all I needed to do was upgrade the Tensorflow version in the default Dockerfile:

FROM tensorflow/tensorflow:1.13.2-gpu-py3
Enzo90910 commented 1 year ago

If you are building the cpu Dockerfile, of course use FROM tensorflow/tensorflow:1.13.2-py3 instead.