Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running on google colab #73

Open
George3d6 opened this issue Mar 4, 2023 · 3 comments
Open

Error running on google colab #73

George3d6 opened this issue Mar 4, 2023 · 3 comments

Comments

@George3d6
Copy link

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
Copy link
Author

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
Copy link
Author

Further things I tried were:

  • Install accelerate<=0.15.0 since I assume the latest release might be causing issues
  • Set num_gpus=0 since I assumed the colab env not having GPUs might also be the issue

@George3d6
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant