Cannot access gated repo issue!
It(The exact file, codes, and the gradio environment) worked on my local device just fine but when I was trying to run/deploy the space here, it gave me the following error: "Cannot access gated repo for URL https://huggingface.co/google/gemma-2b/resolve/main/config.json."
Repo model google/gemma-2b is gated. You must be authenticated to access it.
So, to solve that, I added a secret key to my 'space' setting and passed it to the huggingface_hub login like this:
HUGGINGFACE_TOKEN = os.environ.get("HUGGINGFACE_TOKEN")
login(token=HUGGINGFACE_TOKEN)
It didn't solve the issue. Could anyone please help me with that? Thanks in advance!
Running into the same issue, bypass was to get through Kaggle.
Running into the same issue, the bypass was to get through Kaggle.
Were you able to deploy it here? I could run it on Kaggle and also on my local PC, but not here on HuggingFace.
Hi
@asif00
, sorry you're facing this issue. Could you create a token in your user settings (https://huggingface.co/settings/tokens) and set it as HF_TOKEN
secret in your Space. No need to use login(...)
anymore when doing so. If you have yourself access to https://huggingface.co/google/gemma-2b/tree/main from the browser (which seems to be the case), it should work in the Space as well. Please let me know if this doesn't solve your issue.
Also failed with Cannot access gated repo for url https://huggingface.co/google/gemma-2b/resolve/main/config.json. Repo model google/gemma-2b is gated. You must be authenticated to access it.
running local and my code as follow:
from transformers import AutoTokenizer, AutoModelForCausalLM
access_token='hf_******'
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b")
model = AutoModelForCausalLM.from_pretrained("google/gemma-2b", token=access_token)
input_text = "Write me a poem about Machine Learning."
input_ids = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))
@chuanfengx64 Could you check this Space I've just created: https://huggingface.co/spaces/Wauplin/tmp_for_gemma_discussion_11/blob/main/app.py.
Instead of hardcoding my user token, I set it as HF_TOKEN
in the Space secrets (e.g. in https://huggingface.co/spaces/Wauplin/tmp_for_gemma_discussion_11/settings) which a valid token that I generated for it. And then everything works fine and the files are downloaded correctly.
Hi @Wauplin , thanks for your reply, I can't access your Space with 404.
Oops sorry @chuanfengx64 , it was private while I was debugging it. Should be good now!
Also failed with
Cannot access gated repo for url https://huggingface.co/google/gemma-2b/resolve/main/config.json. Repo model google/gemma-2b is gated. You must be authenticated to access it.
running local and my code as follow:
from transformers import AutoTokenizer, AutoModelForCausalLM access_token='hf_******' tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b") model = AutoModelForCausalLM.from_pretrained("google/gemma-2b", token=access_token) input_text = "Write me a poem about Machine Learning." input_ids = tokenizer(input_text, return_tensors="pt") outputs = model.generate(**input_ids) print(tokenizer.decode(outputs[0]))
Oh! tokenizer should be also with token!!
@Yhnf
How do you try to access it? If I go to https://huggingface.co/spaces/Wauplin/tmp_for_gemma_discussion_11 with incognito mode (e.g. not logged in), it works for me. This Space is not really interesting though, it was just to demonstrate how to load gemma weights in transformers
in a Space by handling authentication with a HF_TOKEN
secret.
No worries, glad it's figured out :)
Hi @asif00 , sorry you're facing this issue. Could you create a token in your user settings (https://huggingface.co/settings/tokens) and set it as
HF_TOKEN
secret in your Space. No need to uselogin(...)
anymore when doing so. If you have yourself access to https://huggingface.co/google/gemma-2b/tree/main from the browser (which seems to be the case), it should work in the Space as well. Please let me know if this doesn't solve your issue.
@Wauplin Thank you so much for your kind response. It worked like a charm!