Repository navigation
Description
from unsloth import FastLanguageModel
import torch
AttributeError Traceback (most recent call last)
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/utils/import_utils.py:1863, in _LazyModule._get_module(self, module_name)
1862 try:
-> 1863 return importlib.import_module("." + module_name, self.name)
1864 except Exception as e:
File ~/miniconda3/envs/unsloth_env/lib/python3.11/importlib/init.py:126, in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File :1204, in _gcd_import(name, package, level)
File :1176, in find_and_load(name, import)
File :1147, in find_and_load_unlocked(name, import)
File :690, in _load_unlocked(spec)
File :940, in exec_module(self, module)
File :241, in _call_with_frames_removed(f, *args, **kwds)
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/modeling_utils.py:53
52 from .integrations.sdpa_attention import sdpa_attention_forward
---> 53 from .loss.loss_utils import LOSS_MAPPING
54 from .pytorch_utils import ( # noqa: F401
55 Conv1D,
56 apply_chunking_to_forward,
(...)
62 translate_to_torch_parallel_style,
63 )
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/loss/loss_utils.py:19
17 from torch.nn import BCEWithLogitsLoss, MSELoss
---> 19 from .loss_deformable_detr import DeformableDetrForObjectDetectionLoss, DeformableDetrForSegmentationLoss
20 from .loss_for_object_detection import ForObjectDetectionLoss, ForSegmentationLoss
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/loss/loss_deformable_detr.py:4
2 import torch.nn as nn
----> 4 from ..image_transforms import center_to_corners_format
5 from ..utils import is_scipy_available
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/image_transforms.py:22
20 import numpy as np
---> 22 from .image_utils import (
23 ChannelDimension,
24 ImageInput,
25 get_channel_dimension_axis,
26 get_image_size,
27 infer_channel_dimension_format,
28 )
29 from .utils import ExplicitEnum, TensorType, is_jax_tensor, is_tf_tensor, is_torch_tensor
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/image_utils.py:65
64 if is_torchvision_available():
---> 65 from torchvision import io as torchvision_io
66 from torchvision.transforms import InterpolationMode
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/torchvision/init.py:10
9 from .extension import _HAS_OPS # usort:skip
---> 10 from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils # usort:skip
12 try:
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/torchvision/_meta_registrations.py:25
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]")
File ~/miniconda3/envs/unsloth_env/lib/python3.11/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)
AttributeError: partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/utils/import_utils.py:1863, in _LazyModule._get_module(self, module_name)
1862 try:
-> 1863 return importlib.import_module("." + module_name, self.name)
1864 except Exception as e:
File ~/miniconda3/envs/unsloth_env/lib/python3.11/importlib/init.py:126, in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File :1204, in _gcd_import(name, package, level)
File :1176, in find_and_load(name, import)
File :1147, in find_and_load_unlocked(name, import)
File :690, in _load_unlocked(spec)
File :940, in exec_module(self, module)
File :241, in _call_with_frames_removed(f, *args, **kwds)
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/integrations/integration_utils.py:36
34 import packaging.version
---> 36 from .. import PreTrainedModel, TFPreTrainedModel
37 from .. import version as version
File :1229, in handle_fromlist(module, fromlist, import, recursive)
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/utils/import_utils.py:1851, in _LazyModule.getattr(self, name)
1850 elif name in self._class_to_module.keys():
-> 1851 module = self._get_module(self._class_to_module[name])
1852 value = getattr(module, name)
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/utils/import_utils.py:1865, in _LazyModule._get_module(self, module_name)
1864 except Exception as e:
-> 1865 raise RuntimeError(
1866 f"Failed to import {self.name}.{module_name} because of the following error (look up to see its"
1867 f" traceback):\n{e}"
1868 ) from e
RuntimeError: Failed to import transformers.modeling_utils because of the following error (look up to see its traceback):
partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
Cell In[10], line 1
----> 1 from unsloth import FastLanguageModel
2 import torch
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/unsloth/init.py:212
209 raise ImportError("Unsloth: Please install unsloth_zoo via pip install unsloth_zoo")
210 pass
--> 212 from .models import *
213 from .save import *
214 from .chat_templates import *
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/unsloth/models/init.py:16
1 # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
(...)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
---> 16 from .granite import FastGraniteModel
17 from .loader import FastLanguageModel, FastVisionModel
18 from .llama import FastLlamaModel
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/unsloth/models/granite.py:15
1 # Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
(...)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
---> 15 from .llama import *
16 import os
17 from ._utils import version
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/unsloth/models/llama.py:20
18 from functools import partial
19 from typing import Optional, Tuple, List, Union
---> 20 from ._utils import *
21 from ._utils import version
22 from torch.nn.functional import scaled_dot_product_attention
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/unsloth/models/_utils.py:147
144 del transformers_training_args_logger
146 # No label_names provided for model class
--> 147 from transformers.trainer import logger as transformers_trainer_logger
148 transformers_trainer_logger.addFilter(HideLoggingMessage("No label_names"))
149 del transformers_trainer_logger
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/trainer.py:42
37 from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Type, Union
40 # Integrations must be imported before ML frameworks:
41 # isort: off
---> 42 from .integrations import (
43 get_reporting_integration_callbacks,
44 )
46 # isort: on
48 import huggingface_hub.utils as hf_hub_utils
File :1229, in handle_fromlist(module, fromlist, import, recursive)
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/utils/import_utils.py:1851, in _LazyModule.getattr(self, name)
1849 value = Placeholder
1850 elif name in self._class_to_module.keys():
-> 1851 module = self._get_module(self._class_to_module[name])
1852 value = getattr(module, name)
1853 elif name in self._modules:
File ~/miniconda3/envs/unsloth_env/lib/python3.11/site-packages/transformers/utils/import_utils.py:1865, in _LazyModule._get_module(self, module_name)
1863 return importlib.import_module("." + module_name, self.name)
1864 except Exception as e:
-> 1865 raise RuntimeError(
1866 f"Failed to import {self.name}.{module_name} because of the following error (look up to see its"
1867 f" traceback):\n{e}"
1868 ) from e
RuntimeError: Failed to import transformers.integrations.integration_utils because of the following error (look up to see its traceback):
Failed to import transformers.modeling_utils because of the following error (look up to see its traceback):
partially initialized module 'torchvision' has no attribute 'extension' (most likely due to a circular import)
Activity
z-x-x136 commentedon Feb 22, 2025
torch 2.6.0
torchaudio 2.4.1+cu121
torchvision 0.21.0
unsloth 2025.2.15
unsloth_zoo 2025.2.7
uri-template 1.3.0
urllib3 2.3.0
wcwidth 0.2.13
webcolors 24.11.1
webencodings 0.5.1
websocket-client 1.8.0
wheel 0.45.1
widgetsnbextension 4.0.13
xformers 0.0.28.post1
xxhash 3.5.0
yarl 1.18.3
zipp 3.21.0
z-x-x136 commentedon Feb 22, 2025
cuda12.1 linux
z-x-x136 commentedon Feb 22, 2025
python=3.11
horiacristescu commentedon Mar 6, 2025
I tried dozens of times and I can't install unsloth in Azure or GCP in a VM with GPU.
ItzAmirreza commentedon Mar 10, 2025
Getting the same error on raw continues fine tuning: