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

KeyError: 'HF_HOME' #13

Closed
fallcat opened this issue Jul 2, 2022 · 4 comments
Closed

KeyError: 'HF_HOME' #13

fallcat opened this issue Jul 2, 2022 · 4 comments

Comments

@fallcat
Copy link

fallcat commented Jul 2, 2022

Hi!
I was trying to run the example in README, but it says KeyError: 'HF_HOME'
This is the script I used: python -m src.pl_train -c t03b.json+rte.json -k save_model=False exp_name=first_exp
I can't find anywhere in the code that sets the value of this environment variable.

Mark experiment first_exp as claimed
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Using bfloat16 Automatic Mixed Precision (AMP)
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
Traceback (most recent call last):
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/weiqiuyou/Documents/codebases/t-few/src/pl_train.py", line 86, in <module>
    main(config)
  File "/Users/weiqiuyou/Documents/codebases/t-few/src/pl_train.py", line 57, in main
    trainer.fit(model, datamodule)
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 741, in fit
    self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 685, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 777, in _fit_impl
    self._run(model, ckpt_path=ckpt_path)
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1131, in _run
    self._data_connector.prepare_data()
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/site-packages/pytorch_lightning/trainer/connectors/data_connector.py", line 154, in prepare_data
    self.trainer.datamodule.prepare_data()
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/site-packages/pytorch_lightning/core/datamodule.py", line 474, in wrapped_fn
    fn(*args, **kwargs)
  File "/Users/weiqiuyou/Documents/codebases/t-few/src/data/data_module.py", line 17, in prepare_data
    _ = self.dataset_reader.read_few_shot_dataset()
  File "/Users/weiqiuyou/Documents/codebases/t-few/src/data/dataset_readers.py", line 164, in read_few_shot_dataset
    orig_data = self.read_orig_dataset("train")
  File "/Users/weiqiuyou/Documents/codebases/t-few/src/data/dataset_readers.py", line 146, in read_orig_dataset
    orig_data = load_dataset(*self.dataset_stash, split=split, cache_dir=os.environ["HF_HOME"])
  File "/Users/weiqiuyou/opt/miniconda3/envs/tfew/lib/python3.7/os.py", line 678, in __getitem__
    raise KeyError(key) from None
KeyError: 'HF_HOME'
@CaffreyR
Copy link

CaffreyR commented Jul 4, 2022

I have encountered the same problems! @dptam @muqeeth @jmohta

@CaffreyR
Copy link

CaffreyR commented Jul 5, 2022

Same error in python -m src.pl_train -c t011b.json+rte.json -k save_model=False exp_name=first_exp

@muqeeth
Copy link
Collaborator

muqeeth commented Jul 5, 2022

Hi,
HF_HOME is an environment variable that can be set running the following command in terminal:
export HF_HOME=/<directory_path_for_huggingface_cache>/

where <directory_path_for_huggingface_cache> can be any directory that can store huggingface cache.

This link https://stackoverflow.com/questions/63312859/how-to-change-huggingface-transformers-default-cache-directory is to set transformers cache directory but the idea is the same for huggingface cache too.
I hope it helps.

@fallcat fallcat closed this as completed Jul 5, 2022
@fallcat
Copy link
Author

fallcat commented Jul 5, 2022

Thank you!

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

3 participants