mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #206] NotImplementedError when clip.load #180
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#180
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DtYXs on GitHub (Jan 6, 2022).
Original GitHub issue: https://github.com/openai/CLIP/issues/206
When running model, preprocess = clip.load("ViT-B/32", device=device)
D:\Anaconda\anaconda3\envs\A\lib\site-packages\torch\serialization.py:591: UserWarning: 'torch.load' received a zip file that looks like a TorchScript archive dispatching to 'torch.jit.load' (call 'torch.jit.load' directly to silence this warning)
" silence this warning)", UserWarning)
Traceback (most recent call last):
File "D:\python\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:\models.py", line 191, in
model = CLIP(cfg)
File "D:\models.py", line 173, in init
self.model, self.preprocess = clip.load("ViT-B/32", device=device)
File "D:\Anaconda\anaconda3\envs\A\lib\site-packages\clip\clip.py", line 135, in load
model = build_model(state_dict or model.state_dict()).to(device)
File "D:\Anaconda\anaconda3\envs\A\lib\site-packages\clip\model.py", line 396, in build_model
vit = "visual.proj" in state_dict
File "D:\Anaconda\anaconda3\envs\A\lib\site-packages\torch\jit_script.py", line 624, in contains
return self.forward_magic_method("contains", key)
File "D:\Anaconda\anaconda3\envs\A\lib\site-packages\torch\jit_script.py", line 611, in forward_magic_method
raise NotImplementedError()
NotImplementedError
How do I solve this problem?
@haofanwang commented on GitHub (Jan 6, 2022):
Try
model, preprocess = clip.load("ViT-B/32", device=device, jit=False)@DtYXs commented on GitHub (Jan 6, 2022):
The problem still occurs. Beacuse
jitdefaults toFasle.It seems that the
state_dictinvit = "visual.proj" in state_dictistorch.jit._script.RecursiveScriptModuleclass,and when call
"visual.proj" in state_dict, the error occurred.My environment and version are executed according to the commands in the document. But it is in Windows. Does it matter?
@haofanwang commented on GitHub (Jan 6, 2022):
github.com/openai/CLIP@573315e83f/clip/clip.py (L125)It seems that this line fails, a runtime exception is raised. Could you move it before
try, do you still meet the same issue?@DtYXs commented on GitHub (Jan 6, 2022):
Thank you very much for your reply. I move it, and
Traceback (most recent call last):
File "D:\python\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/models.py", line 172, in init
self.model, self.preprocess = clip.load("ViT-B/32", device=self.cfg.device, jit=False)
File "D:\Anaconda\anaconda3\envs\A\lib\site-packages\clip\clip.py", line 122, in load
model = torch.jit.load(model_path, map_location=device if jit else "cpu").eval()
File "D:\Anaconda\anaconda3\envs\A\lib\site-packages\torch\jit_serialization.py", line 161, in load
cpp_module = torch._C.import_ir_module(cu, str(f), map_location, _extra_files)
RuntimeError: open file failed because of errno 42 on fopen: Illegal byte sequence, file path: C:\Users\Administrator/.cache/clip\ViT-B-32.pt
python-BaseException
I think the problem comes from my CUDA version is
11.1.Since pytorch seems to have no cudatookit for
11.1(I triedconda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.1butPackagesNotFoundError: The following packages are not available from current channels: cudatoolkit=11.1). Then I triedconda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.0andconda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.3two environments. Each environment has problems.@ZZZ9116 commented on GitHub (Mar 1, 2022):
Hi, I have got the same problem. Did you solve it?
@DtYXs commented on GitHub (Mar 1, 2022):
Actually not, I still cannot run it in my Windows system Cuda11.1 Pytorch1.7.1.
But I can run it in the other server Linux Ubuntu18.04.5 Cuda11.1 Python3.7.9 Pytorch1.9.1.
@rohaldb commented on GitHub (Mar 15, 2022):
I am also having this issue - any update?
@liuxingbaoyu commented on GitHub (Apr 4, 2022):
Maybe because the windows username contains non-ascii characters, this is a pytorch bug
Modify clip.py
github.com/openai/CLIP@40f5484c1c/clip/clip.py (L125-L134)@samuela commented on GitHub (Feb 22, 2023):
Same issue here with Ubuntu and CUDA 11.1 even after https://github.com/openai/CLIP/pull/227.Update: it was a GPU driver issue.
torch.cuda.is_available()was false, sodevice="cuda"failed.