I am facing below issue while loading the pretrained model from HuggingFace.
HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /roberta-base/resolve/main/config.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)')))
The line that is causing the issue is
tokenizer = AutoTokenizer.from_pretrained('roberta-base')
I never faced this issue before and it was working absolutely fine earlier. I am clueless.
Adding the following to the top of the code worked for me:
import requests
from huggingface_hub import configure_http_backend
def backend_factory() -> requests.Session:
session = requests.Session()
session.verify = False
return session
configure_http_backend(backend_factory=backend_factory)
For Enterprise users, if your Enterprise has enterprise root certs, you may need to set this environment variable to know where your ca-certificates.crt bundle is. Testing via the requests module was not able to reproduce the error as those requests went out properly, but for the pull to work via Huggingface we had to set this variable first.
Hope this saves someone a few hours :)
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With