[GH-ISSUE #342] ResourceWarning: unclosed file #297

Open
opened 2026-10-31 21:13:33 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @ibuda on GitHub (Apr 2, 2023).
Original GitHub issue: https://github.com/openai/CLIP/issues/342

Thank you for such a great product OpenAI!
Has anyone met such a warning message when loading model via?

import clip
import torch

device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = clip.load("ViT-B/32", device=device)

warning message:

[/home/user/prb/anaconda3/lib/python3.7/site-packages/clip/clip.py:69](https://file+.vscode-resource.vscode-cdn.net/home/user/prb/anaconda3/lib/python3.7/site-packages/clip/clip.py:69): ResourceWarning: unclosed file <_io.BufferedReader name='[/home/user/.cache/clip/ViT-B-32.pt](https://file+.vscode-resource.vscode-cdn.net/home/user/.cache/clip/ViT-B-32.pt)'>
  if hashlib.sha256(open(download_target, "rb").read()).hexdigest() != expected_sha256:
ResourceWarning: Enable tracemalloc to get the object allocation traceback

torch version is: 1.9.1+cu102
clip version is current, as of this moment.

Originally created by @ibuda on GitHub (Apr 2, 2023). Original GitHub issue: https://github.com/openai/CLIP/issues/342 Thank you for such a great product OpenAI! Has anyone met such a warning message when loading model via? ``` import clip import torch device = "cuda" if torch.cuda.is_available() else "cpu" model, preprocess = clip.load("ViT-B/32", device=device) ``` warning message: ``` [/home/user/prb/anaconda3/lib/python3.7/site-packages/clip/clip.py:69](https://file+.vscode-resource.vscode-cdn.net/home/user/prb/anaconda3/lib/python3.7/site-packages/clip/clip.py:69): ResourceWarning: unclosed file <_io.BufferedReader name='[/home/user/.cache/clip/ViT-B-32.pt](https://file+.vscode-resource.vscode-cdn.net/home/user/.cache/clip/ViT-B-32.pt)'> if hashlib.sha256(open(download_target, "rb").read()).hexdigest() != expected_sha256: ResourceWarning: Enable tracemalloc to get the object allocation traceback ``` torch version is: `1.9.1+cu102` clip version is current, as of this moment.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#297
No description provided.