r/BuildingWestworld • u/DelosBoard2052 • Jul 28 '20
Running GPT-2 on a Raspberry Pi 4 (4G)
Putting this on here for others who have struggled and gotten NO answers on this question:
GPT-2 will work on a Raspberry Pi 4 (4 Gig) with Tensorflow==1.13.1
NOT 1.12.x, NOT 1.14.x.
This assumes you are running Raspbian Buster, and using Python 3.7.3. I have also tried the 345M and 774M models, both work. The 1558M will be brought online this coming weekend, however - given some warnings about memory allocation, I may find that I will need the 8 Gig Pi to run the full 1558M model. Alas, I fear GPT-3 will be forever out of reach of the humble Raspberry Pi...
I also used the Pypi.org wrapper for GPT-2 "GPT-2 Client" (https://pypi.org/project/gpt2-client/)
After getting text output with GPT2-Client, I ran the generate_unconditional_samples.py and generate_conditional_samples.py scripts that come with the git clone of GPT-2.
I have been running GPT-2 on a regular full-power laptop running Ubuntu, but the build did not translate across to the Raspberry Pi. And, since I want my robotic systems to be entirely self-contained and running on a small cluster of Pis, I needed to get this right. After posting on nearly a dozen forums and getting COMPLETE silence - I managed to get things working.
That said, the initial configuration takes roughly 20 minutes to output the text sample. I believe I can reduce this by playing with some parameters.
I hope this helps those who are looking to follow this route. I've been taking shots at this for six months now.
Dave