dinov2 icon indicating copy to clipboard operation
dinov2 copied to clipboard

Unauthorized?

Open jspsiy opened this issue 10 months ago • 2 comments

Hi i'm having some problems downloading your model through torch.hub.load .

dinov2_model = torch.hub.load('facebookresearch/dinov2', 'dinov2_vitl14',pretrained=True)

File "/home/joshua/.conda/envs/cgen/lib/python3.9/site-packages/torch/hub.py", line 638, in load repo_or_dir = _get_cache_or_reload( File "/home/joshua/.conda/envs/cgen/lib/python3.9/site-packages/torch/hub.py", line 258, in _get_cache_or_reload _validate_not_a_forked_repo(repo_owner, repo_name, ref) File "/home/joshua/.conda/envs/cgen/lib/python3.9/site-packages/torch/hub.py", line 203, in _validate_not_a_forked_repo response = json.loads(_read_url(Request(url, headers=headers))) File "/home/joshua/.conda/envs/cgen/lib/python3.9/site-packages/torch/hub.py", line 185, in _read_url with urlopen(url) as r: File "/home/joshua/.conda/envs/cgen/lib/python3.9/urllib/request.py", line 214, in urlopen return opener.open(url, data, timeout) File "/home/joshua/.conda/envs/cgen/lib/python3.9/urllib/request.py", line 523, in open response = meth(req, response) File "/home/joshua/.conda/envs/cgen/lib/python3.9/urllib/request.py", line 632, in http_response response = self.parent.error( File "/home/joshua/.conda/envs/cgen/lib/python3.9/urllib/request.py", line 561, in error return self._call_chain(*args) File "/home/joshua/.conda/envs/cgen/lib/python3.9/urllib/request.py", line 494, in _call_chain result = func(*args) File "/home/joshua/.conda/envs/cgen/lib/python3.9/urllib/request.py", line 641, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 401: Unauthorized

What's going on?

jspsiy avatar Feb 10 '25 14:02 jspsiy

Hey, this is more related to torch hub given the stack trace. But i've just had the same issue (also for Dinov2) , and turn out i had some env var for github set that were interfering. Might be the same for you.

Azreal42 avatar Apr 02 '25 21:04 Azreal42

I had the same error and @Azreal42 gave the right hint. I could resolve it with

unset GITHUB_TOKEN

EDIT: I created a PR to fix this issue in PyTorch. https://github.com/pytorch/pytorch/pull/159896

99991 avatar Aug 05 '25 18:08 99991