When running as python module - meta-llama/Llama-2-7b-hf does not appear to have a file named config.json 
Author: TJKlein
Pull request: no

### System Info

* Python 3.10
* Transformer 4.32.0.dev0
* Transformer 4.34.0.dev0
* huggingface-hub-0.18.0.dev0
* huggingface-hub-0.16.4

### Who can help?

@ArthurZucker 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

When I run the following script (test.py) as module:

```python
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf")
```

and place it in a folder, e.g. scripts.

When I run it with ```python -m scripts.test.py```

I get the following error:

```
Traceback (most recent call last):
  File "/opt/conda/envs/open-instruct/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/conda/envs/deeo/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/home/ubuntu/open-instruct/script/test.py", line 2, in <module>
    model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf")
  File "/opt/conda/envs/open-instruct/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 479, in from_pretrained
    config, kwargs = AutoConfig.from_pretrained(
  File "/opt/conda/envs/open-instruct/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 1004, in from_pretrained
    config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "/opt/conda/envs/open-instruct/lib/python3.10/site-packages/transformers/configuration_utils.py", line 620, in get_config_dict
    config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "/opt/conda/envs/open-instruct/lib/python3.10/site-packages/transformers/configuration_utils.py", line 675, in _get_config_dict
    resolved_config_file = cached_file(
  File "/opt/conda/envs/open-instruct/lib/python3.10/site-packages/transformers/utils/hub.py", line 398, in cached_file
    raise EnvironmentError(
OSError: meta-llama/Llama-2-7b-hf does not appear to have a file named config.json. Checkout 'https://huggingface.co/meta-llama/Llama-2-7b-hf/None' for available files.
```

However, I only get this behavior with Llama. The script works perfectly well when replacing the model with other models such as ```facebook/opt-125m```.

Also, running the python not as a module (```python test.py```) works as expected.

Also, replacing ```meta-llama/Llama-2-7b-hf ``` with the absolute path of the cache works, e.g. ```/home/ubuntu/.cache/huggingface/hub/models--meta-llama--Llama-2-7b-hf/snapshots/afasd1eacsadasdasdsdas113cada```.

### Expected behavior

I would expect the model to load normally:
```
Downloading (…)fetensors.index.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 26.8k/26.8k [00:00<00:00, 137MB/s]
Downloading (…)of-00002.safetensors: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 9.98G/9.98G [02:19<00:00, 71.3MB/s]
Downloading (…)of-00002.safetensors: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 3.50G/3.50G [01:33<00:00, 37.6MB/s]
Downloading shards: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [03:53<00:00, 116.56s/it]
Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [01:39<00:00, 49.75s/it]
Downloading (…)neration_config.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████| 188/188 [00:00<00:00, 200kB/s]
```

Comments:
Hey @TJKlein, interesting problem!

Unfortunately, I cannot reproduce. I followed your same setup, moved the module `test.py` within a folder `scripts` and launched it with `python -m scripts.test.py` and obtained the following result:

```py
(.env) (base) lysandre@x:~/scratch$ python -m scripts.test.py
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████| 2/2 [00:02<00:00,  1.08s/it]
```

The fact that it is only linked with the llama checkpoints from your side makes me wonder whether this isn't a setup issue, a specific folder name for example. We don't do anything specific for llama. 

The only other thing I can think of is that llama is gated; maybe in one situation your HF token is identified correctly and the model can be loaded, and in another, it is not and your script doesn't manage to access the gated checkpoints?

Hi @LysandreJik,

it is indeed a very weird problem. I spun up another EC2 instance and also could not replicate it there. However, I have another EC2 instance where exactly the same issue occurs.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.