Skip to content
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

ImportError: cannot import name 'get_ctx' from 'torch.library' #195

Open
candykilla opened this issue Dec 15, 2024 · 3 comments
Open

ImportError: cannot import name 'get_ctx' from 'torch.library' #195

candykilla opened this issue Dec 15, 2024 · 3 comments

Comments

@candykilla
Copy link

image
what should I do ?

@hbb1
Copy link
Owner

hbb1 commented Dec 19, 2024

is there something wrong with the torch?

@sbmalik
Copy link

sbmalik commented Jan 15, 2025

@candykilla have you solved it? If yes how?

@SpoonSecOps
Copy link

Just faced the same issue.

Cell In[12], line 3
1 # Pytorch
2 import torch
----> 3 from torchvision import datasets, transforms
5 # Sklearn works with numpy
6 from numpy import asarray

File c:\Users\pasca\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision_init_.py:10
7 # Don't re-order these, we need to load the _C extension (done when importing
8 # .extensions) before entering _meta_registrations.
9 from .extension import _HAS_OPS # usort:skip
---> 10 from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils # usort:skip
12 try:
13 from .version import version # noqa: F401

File c:\Users\pasca\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision_meta_registrations.py:4
1 import functools
3 import torch
----> 4 import torch._custom_ops
5 import torch.library
7 # Ensure that torch.ops.torchvision is visible

File c:\Users\pasca\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_custom_ops.py:11
2 import inspect
4 from torch._custom_op.impl import (
5 _custom_op_with_schema,
6 _find_custom_op,
(...)
9 validate_namespace,
10 )
---> 11 from torch.library import get_ctx
14 all = [
15 "custom_op",
16 "impl",
(...)
20 "impl_backward",
21 ]
24 def custom_op(qualname, func_or_schema=None):

ImportError: cannot import name 'get_ctx' from 'torch.library' (c:\Users\pasca\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\library.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants