while trying to install GPT2 according to the instructions on the official github repo, I ended up with an Illigal hardware instruction
error when I tried to use it.
that means I shouldn't even think of trying GPT2 on an M1 pro chip
(though the instructions are incomplete because it doesn't tell you what python and pip version to use to install tensorflow, it just says you need tensorflow 1.12.0 so, from the official tensorflow website and by connecting the dots from the instructions there, I figured I needed python3.8 and also since I have MacOS).
after this dead-end and before I gave up on this beautiful open source ML model, I discovered in the official apple's github page they have an optimized tensorflow version for MacOS even allowing you to take advantage of the 16 Neural-Engine cores the M1 Pro CPU has. (no one cares about GPU support if you have that)
only problem is the tensorflow this time is a versioned 2.X while GPT2 is using 1.12.0
I don't believe apple will care about backward compatibility, even the 2.X version on their github is archived and on read-only. so there is no intensions we can hope for
the problem between the two versions is the contrib
package was removed.
the top rated answer here (to this day) suggests to "google the name of the module without the tf.contrib part to know its new location and thus migrating the code accordingly by correcting the import statement."
now I have access to the contrib package in the github repo for tensorflow so there is no need for googling I gues.
the first error at this point is on model.py line 6: from tensorflow.contrib.training import HParams
I simply downloaded it from github's repo and pasted it in GPT2's src
I was thinking to keep repeating the same trick until HParams.py asks for: from tensorflow.contrib.training.python.training import hparam_pb2
hparam_pb2 doesn't exist anywhere, so I don't know how to find this extensioned file with *_pb2.py
if anyone is running on the same problem, kindly advise what's next
Asked
Active
Viewed 1,606 times
2
-
This guy ran nanoGPT on an M2 MacBook. I assume it's close enough that it would help you run GPT-2. Give it a try: https://til.simonwillison.net/llms/nanogpt-shakespeare-m2 – Velociround Feb 23 '23 at 12:16