paperswithcode / galai

Model API for GALACTICA
Apache License 2.0
2.67k stars 275 forks source link

Error running on google colab #73

Open George3d6 opened 1 year ago

George3d6 commented 1 year ago
NameError                                 Traceback (most recent call last)

[<ipython-input-42-77feb2eb4300>](https://localhost:8080/#) in <module>
      1 from transformers import AutoTokenizer, OPTForCausalLM
      2 tokenizer = AutoTokenizer.from_pretrained("facebook/galactica-125m")
----> 3 model = OPTForCausalLM.from_pretrained("facebook/galactica-125m", device_map="auto")

[/usr/local/lib/python3.8/dist-packages/transformers/modeling_utils.py](https://localhost:8080/#) in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
   2357             init_contexts = [deepspeed.zero.Init(config_dict_or_path=deepspeed_config())] + init_contexts
   2358         elif load_in_8bit or low_cpu_mem_usage:
-> 2359             init_contexts.append(init_empty_weights())
   2360 
   2361         with ContextManagers(init_contexts):

NameError: name 'init_empty_weights' is not defined

I've installed the latest version of accelerate and transformers, no other libraries

George3d6 commented 1 year ago

The same error occurs if I install galai and try to run it like that:

NameError                                 Traceback (most recent call last)

[<ipython-input-45-baaf28fb626d>](https://localhost:8080/#) in <module>
      1 import galai as gal
----> 2 model = gal.load_model("standard")
      3 model.generate("Scaled dot product attention:\n\n\\[")

2 frames

[/usr/local/lib/python3.8/dist-packages/transformers/modeling_utils.py](https://localhost:8080/#) in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
   2357 
   2358                 model = load_flax_checkpoint_in_pytorch_model(model, resolved_archive_file)
-> 2359             except ImportError:
   2360                 logger.error(
   2361                     "Loading a Flax model in PyTorch, requires both PyTorch and Flax to be installed. Please see"

NameError: name 'init_empty_weights' is not defined
George3d6 commented 1 year ago

Further things I tried were:

George3d6 commented 1 year ago

Nevermind, there was a caching issue, accelerate<=0.15.0 installed before transformers (not 100% sure this is needed but the other way around didn't seem to work) fixed this for me. Will make a PR just in case, feel free to drop it if you don't think it's appropriate. I have my hack and I can move froward with it.