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

AttributeError: partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import) #919

Open
PogusTheWhisper opened this issue Aug 31, 2024 · 6 comments

Comments

@PogusTheWhisper
Copy link

from tsai.basics import *


AttributeError Traceback (most recent call last)
Cell In[52], line 1
----> 1 from tsai.basics import *

File /opt/conda/lib/python3.10/site-packages/tsai/basics.py:5
3 from .imports import *
4 from .utils import *
----> 5 from .data.basics import *
6 from .losses import *
7 from .metrics import *

File /opt/conda/lib/python3.10/site-packages/tsai/data/basics.py:6
4 from .core import *
5 from .preprocessing import *
----> 6 from .transforms import *
7 from .mixed_augmentation import *

File /opt/conda/lib/python3.10/site-packages/tsai/data/transforms.py:21
19 from scipy.ndimage import convolve1d
20 from fastcore.transform import compose_tfms
---> 21 from fastai.vision.augment import RandTransform
22 from ..utils import *
23 from .core import *

File /opt/conda/lib/python3.10/site-packages/fastai/vision/augment.py:116
113 def encodes(self, x:(Image.Image,*TensorTypes)): return x.dihedral(self.k)
115 # %% ../../nbs/09_vision.augment.ipynb 27
--> 116 from torchvision.transforms.functional import pad as tvpad
118 # %% ../../nbs/09_vision.augment.ipynb 28
119 mk_class('PadMode', **{o:o.lower() for o in ['Zeros', 'Border', 'Reflection']},
120 doc="All possible padding mode as attributes to get tab-completion and typo-proofing")

File /opt/conda/lib/python3.10/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 /opt/conda/lib/python3.10/site-packages/torchvision/_meta_registrations.py:26
20 return fn
22 return wrapper
25 @register_meta("roi_align")
---> 26 def meta_roi_align(input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio, aligned):
27 torch._check(rois.size(1) == 5, lambda: "rois must have shape as Tensor[K, 5]")
28 torch._check(
29 input.dtype == rois.dtype,
30 lambda: (
(...)
33 ),
34 )

File /opt/conda/lib/python3.10/site-packages/torchvision/_meta_registrations.py:18, in register_meta..wrapper(fn)
17 def wrapper(fn):
---> 18 if torchvision.extension._has_ops():
19 get_meta_lib().impl(getattr(getattr(torch.ops.torchvision, op_name), overload_name), fn)
20 return fn

AttributeError: partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)

@sallyqiansun
Copy link

Hi, did you fix this?

@shizhediao
Copy link

Same question

@tusg
Copy link

tusg commented Oct 7, 2024

pip install -U torch==2.3.1
pip install torchvision==0.17.2
I was facing the same error tried multiple things...finally these two upgrades worked for me.
i faced this error while running this code -:
https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct-AWQ

@vlamenco
Copy link

vlamenco commented Dec 4, 2024

how to figure it out!~?

@PoyBoi
Copy link

PoyBoi commented Dec 20, 2024

pip install -U torch==2.3.1 pip install torchvision==0.17.2 I was facing the same error tried multiple things...finally these two upgrades worked for me. i faced this error while running this code -: https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct-AWQ

Didn't fix it for me sadly :/ (mis-match of torchvision's older version-set installs torch 2.2.2, overwriting 2.3.1, and even reinstalling torch 2.3.1 over it doesn't fix it)

@AMRA94
Copy link

AMRA94 commented Dec 26, 2024

Hi @PoyBoi . Would be thankful if you could tell me whether you have had any progress over it or not?

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

7 participants