openai / gpt-2

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

Installation, revisited #314

Open Manamama opened 1 year ago

Manamama commented 1 year ago

Summary: Run e.g. this one

sudo docker pull am271/gpt2
sudo docker run --rm -it am271/gpt2 bash
python3 ./download_model.py 345M
python3 src/interactive_conditional_samples.py --model_name 345M

for a properly running version.

Details: Almost nothing has worked out of the box by now, even the dockers way: load metadata for docker.io/tensorflow/tensorflow:1.12.0-gpu-py3: ------ failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = failed to parse /home/codespace/.docker/.token_seed: unexpected end of JSON input @6Y3GRwDjtGVo4nAe2 or

#11 0.791   File "/usr/lib/python3.5/typing.py", line 177, in _eval_type
#11 0.791     eval(self.__forward_code__, globalns, localns),
#11 0.791   File "<string>", line 1, in <module>
#11 0.791 AttributeError: module 'os' has no attribute 'PathLike'
------
executor failed running [/bin/sh -c python3 download_model.py 124M]: exit code: 1

and such, partially resolvable via a docker builders purge plus: rm ~/.docker/.token_seed.loc rm ~/.docker/.token_seed but then:

#11 0.782   File "/usr/lib/python3.5/typing.py", line 177, in _eval_type
#11 0.782     eval(self.__forward_code__, globalns, localns),
#11 0.782   File "<string>", line 1, in <module>
#11 0.782 AttributeError: module 'os' has no attribute 'PathLike'
------
executor failed running [/bin/sh -c python3 download_model.py 124M]: exit code: 1

The tensorflow "dll hell" got worse since then, obviously. Only this below has worked for me so far, so pro memoriam:

# Clone the GPT-2 repository from GitHub
git clone https://github.com/openai/gpt-2.git
conda init 
bash
conda create --name gpt2 python=3.6

etc. to intialize it and then:

#!/bin/bash

# Create conda environment with Python 3.6

# Activate the conda environment
conda activate gpt2
#or source activate gpt2

# Navigate to the cloned repository
cd gpt-2/

# Install required Python packages
pip install -r requirements.txt

# Install TensorFlow and NumPy packages with specific versions
pip install tensorflow==1.15.2 numpy==1.18.0
pip install requests
pip install fire
pip install regex
# Download the 345M model
python3 ./download_model.py 345M

# Run the interactive console with the 345M model
python3 src/interactive_conditional_samples.py --model_name 345M

and then get out: conda deactivate Interestingly, it is OpenAI ChatGPT plus Bing Chat , the daughers of this one, who has helped me troubleshoot these.

The Github Spaces box where mine runs, another fyi:

~/Downloads/gpt-2 (master) $ neofetch

OS: Ubuntu 20.04.5 LTS x86_64 Kernel: 5.4.0-1103-azure CPU: Intel Xeon Platinum 8272CL (4) @ 2.5GHz Memory: 2019MiB / 7957MiB Shell: /bin/bash 5.0.17 Python: 3.10.4


Uptime: 1 day, 1 hour, 41 mins Packages: 844 (dpkg) Terminal: /dev/pts/0


CPU Usage: 2% Disk (/): 17G / 31G (59%)


Host: Virtual Machine 7.0 Public IP: 20.105.169.104

Ver. 1.0.1

yingqianch commented 5 months ago

Thank you very much. Sloved my problems.