-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: 'torch._C.Node' object is not subscriptable #79
Comments
Likely related to PyTorch 1.8. Please try loading with |
@jongwook This very unclear and strange solution helped me microsoft/nni#2574 - so If someone will face the same problem - just import torchvision |
This change follows from the discussion[1,2] OpenAI CLIP issue tracker and final fix[3] of the following error: ``` TypeError: 'torch._C.Node' object is not subscriptable ``` [1]: openai/CLIP#79 [2]: openai/CLIP#49 [3]: openai/CLIP@db20393
This doesn't work for me. |
FWIW I've found the same error on Ubuntu 20.04, with PyTorch 2.0.0 and CLIP a9b1bf5. Update: setting |
thanks, It is helpful for me。 |
For torch 2.0.0 this is working to monkeypatch the subscript operator: import torch
import clip
# From https://github.com/pytorch/pytorch/blob/2efe4d809fdc94501fc38bf429e9a8d4205b51b6/torch/utils/tensorboard/_pytorch_graph.py#L384
def _node_get(node: torch._C.Node, key: str):
"""Gets attributes of a node which is polymorphic over return type."""
sel = node.kindOf(key)
return getattr(node, sel)(key)
torch._C.Node.__getitem__ = _node_get
model, preprocess = clip.load('ViT-B/32', jit=True) |
Traceback (most recent call last):
File "D:/openai/CLIP/test1.py", line 7, in
model, preprocess = clip.load("ViT-B/32", device=device)
File "D:\openai\CLIP\clip\clip.py", line 133, in load
model.apply(patch_device)
File "D:\conda\envs\my_pytorch\lib\site-packages\torch\nn\modules\module.py", line 445, in apply
module.apply(fn)
File "D:\conda\envs\my_pytorch\lib\site-packages\torch\nn\modules\module.py", line 445, in apply
module.apply(fn)
File "D:\conda\envs\my_pytorch\lib\site-packages\torch\nn\modules\module.py", line 446, in apply
fn(self)
File "D:\openai\CLIP\clip\clip.py", line 130, in patch_device
if "value" in node.attributeNames() and str(node["value"]).startswith("cuda"):
TypeError: 'torch._C.Node' object is not subscriptable
The text was updated successfully, but these errors were encountered: