huggingface / optimum-intel

๐Ÿค— Optimum Intel: Accelerate inference with Intel optimization tools

Home Page:https://huggingface.co/docs/optimum/main/en/intel/index

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

INCStableDiffusionPipeline toolkit

JiaojiaoYe1994 opened this issue ยท comments

commented

Hi, guys, thank for the pretty cool project. One question regarding the use of Neural Compressor as the following. I guess it is the version problem and tries to reinstall Neural Compressor by python -m pip install optimum[neural-compressor] .

Environment:

  • optimum 1.8.7.dev0
  • neural-compressor 2.2.1

To Reproduce:

from optimum.intel import INCQuantizer, INCStableDiffusionPipeline

Return:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/utils/utility.py:103 in getattr โ”‚
โ”‚ โ”‚
โ”‚ 100 โ”‚ def getattr(self, name): โ”‚
โ”‚ 101 โ”‚ โ”‚ """Get the attributes of the module by name.""" โ”‚
โ”‚ 102 โ”‚ โ”‚ try: โ”‚
โ”‚ โฑ 103 โ”‚ โ”‚ โ”‚ self.module = importlib.import_module(self.module_name) โ”‚
โ”‚ 104 โ”‚ โ”‚ โ”‚ mod = getattr(self.module, name) โ”‚
โ”‚ 105 โ”‚ โ”‚ except: โ”‚
โ”‚ 106 โ”‚ โ”‚ โ”‚ spec = importlib.util.find_spec(str(self.module_name + '.' + name)) โ”‚
โ”‚ โ”‚
โ”‚ /usr/lib/python3.8/importlib/init.py:127 in import_module โ”‚
โ”‚ โ”‚
โ”‚ 124 โ”‚ โ”‚ โ”‚ if character != '.': โ”‚
โ”‚ 125 โ”‚ โ”‚ โ”‚ โ”‚ break โ”‚
โ”‚ 126 โ”‚ โ”‚ โ”‚ level += 1 โ”‚
โ”‚ โฑ 127 โ”‚ return _bootstrap._gcd_import(name[level:], package, level) โ”‚
โ”‚ 128 โ”‚
โ”‚ 129 โ”‚
โ”‚ 130 _RELOADING = {} โ”‚
โ”‚ in _gcd_import:1014 โ”‚
โ”‚ in _find_and_load:991 โ”‚
โ”‚ in _find_and_load_unlocked:975 โ”‚
โ”‚ in _load_unlocked:671 โ”‚
โ”‚ in exec_module:843 โ”‚
โ”‚ in _call_with_frames_removed:219 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/cv2/init.py:181 in โ”‚
โ”‚ โ”‚
โ”‚ 178 โ”‚ if DEBUG: print('OpenCV loader: DONE') โ”‚
โ”‚ 179 โ”‚
โ”‚ 180 โ”‚
โ”‚ โฑ 181 bootstrap() โ”‚
โ”‚ 182 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/cv2/init.py:175 in bootstrap โ”‚
โ”‚ โ”‚
โ”‚ 172 โ”‚ if DEBUG: print('OpenCV loader: binary extension... OK') โ”‚
โ”‚ 173 โ”‚ โ”‚
โ”‚ 174 โ”‚ for submodule in __collect_extra_submodules(DEBUG): โ”‚
โ”‚ โฑ 175 โ”‚ โ”‚ if __load_extra_py_code_for_module("cv2", submodule, DEBUG): โ”‚
โ”‚ 176 โ”‚ โ”‚ โ”‚ if DEBUG: print("Extra Python code for", submodule, "is loaded") โ”‚
โ”‚ 177 โ”‚ โ”‚
โ”‚ 178 โ”‚ if DEBUG: print('OpenCV loader: DONE') โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/cv2/init.py:28 in __load_extra_py_code_for_module โ”‚
โ”‚ โ”‚
โ”‚ 25 โ”‚ export_module_name = "{}.{}".format(base, name) โ”‚
โ”‚ 26 โ”‚ native_module = sys.modules.pop(module_name, None) โ”‚
โ”‚ 27 โ”‚ try: โ”‚
โ”‚ โฑ 28 โ”‚ โ”‚ py_module = importlib.import_module(module_name) โ”‚
โ”‚ 29 โ”‚ except ImportError as err: โ”‚
โ”‚ 30 โ”‚ โ”‚ if enable_debug_print: โ”‚
โ”‚ 31 โ”‚ โ”‚ โ”‚ print("Can't load Python code for module:", module_name, โ”‚
โ”‚ โ”‚
โ”‚ /usr/lib/python3.8/importlib/init.py:127 in import_module โ”‚
โ”‚ โ”‚
โ”‚ 124 โ”‚ โ”‚ โ”‚ if character != '.': โ”‚
โ”‚ 125 โ”‚ โ”‚ โ”‚ โ”‚ break โ”‚
โ”‚ 126 โ”‚ โ”‚ โ”‚ level += 1 โ”‚
โ”‚ โฑ 127 โ”‚ return _bootstrap._gcd_import(name[level:], package, level) โ”‚
โ”‚ 128 โ”‚
โ”‚ 129 โ”‚
โ”‚ 130 _RELOADING = {} โ”‚
โ”‚ in _gcd_import:1014 โ”‚
โ”‚ in _find_and_load:991 โ”‚
โ”‚ in _find_and_load_unlocked:975 โ”‚
โ”‚ in _load_unlocked:671 โ”‚
โ”‚ in exec_module:843 โ”‚
โ”‚ in _call_with_frames_removed:219 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/cv2/mat_wrapper/init.py:33 in โ”‚
โ”‚ โ”‚
โ”‚ 30 โ”‚
โ”‚ 31 Mat.module = cv.name โ”‚
โ”‚ 32 cv.Mat = Mat โ”‚
โ”‚ โฑ 33 cv._registerMatType(Mat) โ”‚
โ”‚ 34 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
AttributeError: partially initialized module 'cv2' has no attribute '_registerMatType' (most likely due to a
circular import)

During handling of the above exception, another exception occurred:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ /usr/local/lib/python3.8/dist-packages/transformers/utils/import_utils.py:1146 in _get_module โ”‚
โ”‚ โ”‚
โ”‚ 1143 โ”‚ โ”‚
โ”‚ 1144 โ”‚ def _get_module(self, module_name: str): โ”‚
โ”‚ 1145 โ”‚ โ”‚ try: โ”‚
โ”‚ โฑ 1146 โ”‚ โ”‚ โ”‚ return importlib.import_module("." + module_name, self.name) โ”‚
โ”‚ 1147 โ”‚ โ”‚ except Exception as e: โ”‚
โ”‚ 1148 โ”‚ โ”‚ โ”‚ raise RuntimeError( โ”‚
โ”‚ 1149 โ”‚ โ”‚ โ”‚ โ”‚ f"Failed to import {self.name}.{module_name} because of the followin โ”‚
โ”‚ โ”‚
โ”‚ /usr/lib/python3.8/importlib/init.py:127 in import_module โ”‚
โ”‚ โ”‚
โ”‚ 124 โ”‚ โ”‚ โ”‚ if character != '.': โ”‚
โ”‚ 125 โ”‚ โ”‚ โ”‚ โ”‚ break โ”‚
โ”‚ 126 โ”‚ โ”‚ โ”‚ level += 1 โ”‚
โ”‚ โฑ 127 โ”‚ return _bootstrap._gcd_import(name[level:], package, level) โ”‚
โ”‚ 128 โ”‚
โ”‚ 129 โ”‚
โ”‚ 130 _RELOADING = {} โ”‚
โ”‚ in _gcd_import:1014 โ”‚
โ”‚ in _find_and_load:991 โ”‚
โ”‚ in _find_and_load_unlocked:975 โ”‚
โ”‚ in _load_unlocked:671 โ”‚
โ”‚ in exec_module:843 โ”‚
โ”‚ in _call_with_frames_removed:219 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/optimum/intel/neural_compressor/init.py:17 in โ”‚
โ”‚ โ”‚
โ”‚ โ”‚
โ”‚ 14 โ”‚
โ”‚ 15 from ..utils.import_utils import is_diffusers_available โ”‚
โ”‚ 16 from .configuration import INCConfig โ”‚
โ”‚ โฑ 17 from .quantization import ( โ”‚
โ”‚ 18 โ”‚ INCModel, โ”‚
โ”‚ 19 โ”‚ INCModelForCausalLM, โ”‚
โ”‚ 20 โ”‚ INCModelForMaskedLM, โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/optimum/intel/neural_compressor/quantization.py:28 in โ”‚
โ”‚ โ”‚
โ”‚ โ”‚
โ”‚ 25 import torch โ”‚
โ”‚ 26 from datasets import Dataset, load_dataset โ”‚
โ”‚ 27 from huggingface_hub import HfApi, hf_hub_download โ”‚
โ”‚ โฑ 28 from neural_compressor.adaptor.pytorch import PyTorch_FXAdaptor, _cfg_to_qconfig, _propa โ”‚
โ”‚ 29 from neural_compressor.config import PostTrainingQuantConfig โ”‚
โ”‚ 30 from neural_compressor.experimental.export import torch_to_int8_onnx โ”‚
โ”‚ 31 from neural_compressor.model.torch_model import IPEXModel, PyTorchModel โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/init.py:24 in โ”‚
โ”‚ โ”‚
โ”‚ 21 from .config import DistillationConfig, PostTrainingQuantConfig, \ โ”‚
โ”‚ 22 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ WeightPruningConfig, QuantizationAwareTrainingConfig, \ โ”‚
โ”‚ 23 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ MixedPrecisionConfig โ”‚
โ”‚ โฑ 24 from .contrib import * โ”‚
โ”‚ 25 from .model import * โ”‚
โ”‚ 26 from .metric import * โ”‚
โ”‚ 27 from .utils import options โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/contrib/init.py:19 in โ”‚
โ”‚ โ”‚
โ”‚ 16 # limitations under the License. โ”‚
โ”‚ 17 โ”‚
โ”‚ 18 """Built-in strategy for multiple framework backends.""" โ”‚
โ”‚ โฑ 19 from .strategy import * โ”‚
โ”‚ 20 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/contrib/strategy/init.py:26 in โ”‚
โ”‚ โ”‚
โ”‚ โ”‚
โ”‚ 23 โ”‚
โ”‚ 24 for f in modules: โ”‚
โ”‚ 25 โ”‚ if isfile(f) and not f.startswith('') and not f.endswith('init.py'): โ”‚
โ”‚ โฑ 26 โ”‚ โ”‚ import(basename(f)[:-3], globals(), locals(), level=1) โ”‚
โ”‚ 27 โ”‚
โ”‚ 28 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/contrib/strategy/tpe.py:26 in โ”‚
โ”‚ โ”‚
โ”‚ 23 import numpy as np โ”‚
โ”‚ 24 from neural_compressor.utils import logger โ”‚
โ”‚ 25 from neural_compressor.utils.utility import LazyImport โ”‚
โ”‚ โฑ 26 from neural_compressor.strategy.strategy import strategy_registry, TuneStrategy โ”‚
โ”‚ 27 from collections import OrderedDict โ”‚
โ”‚ 28 from neural_compressor.strategy.utils.tuning_sampler import OpWiseTuningSampler โ”‚
โ”‚ 29 from neural_compressor.strategy.utils.tuning_structs import OpTuningConfig โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/strategy/init.py:20 in โ”‚
โ”‚ โ”‚
โ”‚ 17 โ”‚
โ”‚ 18 """Intel Neural Compressor Strategy.""" โ”‚
โ”‚ 19 โ”‚
โ”‚ โฑ 20 from .strategy import STRATEGIES โ”‚
โ”‚ 21 from os.path import dirname, basename, isfile, join โ”‚
โ”‚ 22 import glob โ”‚
โ”‚ 23 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/strategy/strategy.py:35 in โ”‚
โ”‚ โ”‚
โ”‚ 32 import numpy as np โ”‚
โ”‚ 33 import yaml โ”‚
โ”‚ 34 โ”‚
โ”‚ โฑ 35 from neural_compressor.adaptor.tensorflow import TensorFlowAdaptor โ”‚
โ”‚ 36 from neural_compressor.config import MixedPrecisionConfig โ”‚
โ”‚ 37 from .utils.constant import FALLBACK_RECIPES_SET โ”‚
โ”‚ 38 from .utils.tuning_space import TuningSpace โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/adaptor/init.py:26 in โ”‚
โ”‚ โ”‚
โ”‚ 23 โ”‚
โ”‚ 24 for f in modules: โ”‚
โ”‚ 25 โ”‚ if isfile(f) and not f.startswith('
') and not f.endswith('init.py'): โ”‚
โ”‚ โฑ 26 โ”‚ โ”‚ import(basename(f)[:-3], globals(), locals(), level=1) โ”‚
โ”‚ 27 โ”‚
โ”‚ 28 all = ["FRAMEWORKS"] โ”‚
โ”‚ 29 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/adaptor/pytorch.py:33 in โ”‚
โ”‚ โ”‚
โ”‚ 30 from ..utils.utility import Statistics โ”‚
โ”‚ 31 from ..utils import logger โ”‚
โ”‚ 32 from .query import QueryBackendCapability โ”‚
โ”‚ โฑ 33 from ..data.dataloaders.base_dataloader import BaseDataLoader โ”‚
โ”‚ 34 torch = LazyImport("torch") โ”‚
โ”‚ 35 json = LazyImport("json") โ”‚
โ”‚ 36 hvd = LazyImport("horovod.torch") โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/data/init.py:22 in โ”‚
โ”‚ โ”‚
โ”‚ 19 โ”‚
โ”‚ 20 โ”‚
โ”‚ 21 import neural_compressor.data.datasets โ”‚
โ”‚ โฑ 22 import neural_compressor.data.transforms โ”‚
โ”‚ 23 from .datasets import Datasets, Dataset, IterableDataset, dataset_registry, TensorflowIm โ”‚
โ”‚ 24 from .dataloaders import DATALOADERS, DataLoader โ”‚
โ”‚ 25 from .dataloaders.dataloader import check_dataloader โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/data/transforms/init.py:20 in โ”‚
โ”‚ โ”‚
โ”‚ โ”‚
โ”‚ 17 # ============================================================================== โ”‚
โ”‚ 18 """Neural Compressor Built-in transforms for multiple framework backends.""" โ”‚
โ”‚ 19 โ”‚
โ”‚ โฑ 20 from .transform import TRANSFORMS, BaseTransform, ComposeTransform, transform_registry, โ”‚
โ”‚ 21 ResizeTFTransform, TensorflowResizeWithRatio, RescaleTFTransform, NormalizeTFTransform โ”‚
โ”‚ 22 from .transform import TFSquadV1PostTransform, TFSquadV1ModelZooPostTransform โ”‚
โ”‚ 23 from .coco_transform import ParseDecodeCocoTransform โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/data/transforms/transform.py:478 in โ”‚
โ”‚ โ”‚
โ”‚ โ”‚
โ”‚ 475 โ”‚ โ”‚ return (image, label) โ”‚
โ”‚ 476 โ”‚
โ”‚ 477 interpolation_map = { โ”‚
โ”‚ โฑ 478 โ”‚ 'nearest': cv2.INTER_NEAREST, โ”‚
โ”‚ 479 โ”‚ 'bilinear': cv2.INTER_LINEAR, โ”‚
โ”‚ 480 โ”‚ 'bicubic': cv2.INTER_CUBIC, โ”‚
โ”‚ 481 } โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/neural_compressor/utils/utility.py:106 in getattr โ”‚
โ”‚ โ”‚
โ”‚ 103 โ”‚ โ”‚ โ”‚ self.module = importlib.import_module(self.module_name) โ”‚
โ”‚ 104 โ”‚ โ”‚ โ”‚ mod = getattr(self.module, name) โ”‚
โ”‚ 105 โ”‚ โ”‚ except: โ”‚
โ”‚ โฑ 106 โ”‚ โ”‚ โ”‚ spec = importlib.util.find_spec(str(self.module_name + '.' + name)) โ”‚
โ”‚ 107 โ”‚ โ”‚ โ”‚ mod = importlib.util.module_from_spec(spec) โ”‚
โ”‚ 108 โ”‚ โ”‚ โ”‚ spec.loader.exec_module(mod) โ”‚
โ”‚ 109 โ”‚ โ”‚ return mod โ”‚
โ”‚ โ”‚
โ”‚ /usr/lib/python3.8/importlib/util.py:94 in find_spec โ”‚
โ”‚ โ”‚
โ”‚ 91 โ”‚ if fullname not in sys.modules: โ”‚
โ”‚ 92 โ”‚ โ”‚ parent_name = fullname.rpartition('.')[0] โ”‚
โ”‚ 93 โ”‚ โ”‚ if parent_name: โ”‚
โ”‚ โฑ 94 โ”‚ โ”‚ โ”‚ parent = import(parent_name, fromlist=['path']) โ”‚
โ”‚ 95 โ”‚ โ”‚ โ”‚ try: โ”‚
โ”‚ 96 โ”‚ โ”‚ โ”‚ โ”‚ parent_path = parent.path โ”‚
โ”‚ 97 โ”‚ โ”‚ โ”‚ except AttributeError as e: โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/cv2/init.py:181 in โ”‚
โ”‚ โ”‚
โ”‚ 178 โ”‚ if DEBUG: print('OpenCV loader: DONE') โ”‚
โ”‚ 179 โ”‚
โ”‚ 180 โ”‚
โ”‚ โฑ 181 bootstrap() โ”‚
โ”‚ 182 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/cv2/init.py:175 in bootstrap โ”‚
โ”‚ โ”‚
โ”‚ 172 โ”‚ if DEBUG: print('OpenCV loader: binary extension... OK') โ”‚
โ”‚ 173 โ”‚ โ”‚
โ”‚ 174 โ”‚ for submodule in __collect_extra_submodules(DEBUG): โ”‚
โ”‚ โฑ 175 โ”‚ โ”‚ if __load_extra_py_code_for_module("cv2", submodule, DEBUG): โ”‚
โ”‚ 176 โ”‚ โ”‚ โ”‚ if DEBUG: print("Extra Python code for", submodule, "is loaded") โ”‚
โ”‚ 177 โ”‚ โ”‚
โ”‚ 178 โ”‚ if DEBUG: print('OpenCV loader: DONE') โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/cv2/init.py:28 in __load_extra_py_code_for_module โ”‚
โ”‚ โ”‚
โ”‚ 25 โ”‚ export_module_name = "{}.{}".format(base, name) โ”‚
โ”‚ 26 โ”‚ native_module = sys.modules.pop(module_name, None) โ”‚
โ”‚ 27 โ”‚ try: โ”‚
โ”‚ โฑ 28 โ”‚ โ”‚ py_module = importlib.import_module(module_name) โ”‚
โ”‚ 29 โ”‚ except ImportError as err: โ”‚
โ”‚ 30 โ”‚ โ”‚ if enable_debug_print: โ”‚
โ”‚ 31 โ”‚ โ”‚ โ”‚ print("Can't load Python code for module:", module_name, โ”‚
โ”‚ โ”‚
โ”‚ /usr/lib/python3.8/importlib/init.py:127 in import_module โ”‚
โ”‚ โ”‚
โ”‚ 124 โ”‚ โ”‚ โ”‚ if character != '.': โ”‚
โ”‚ 125 โ”‚ โ”‚ โ”‚ โ”‚ break โ”‚
โ”‚ 126 โ”‚ โ”‚ โ”‚ level += 1 โ”‚
โ”‚ โฑ 127 โ”‚ return _bootstrap._gcd_import(name[level:], package, level) โ”‚
โ”‚ 128 โ”‚
โ”‚ 129 โ”‚
โ”‚ 130 _RELOADING = {} โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/cv2/mat_wrapper/init.py:33 in โ”‚
โ”‚ โ”‚
โ”‚ 30 โ”‚
โ”‚ 31 Mat.module = cv.name โ”‚
โ”‚ 32 cv.Mat = Mat โ”‚
โ”‚ โฑ 33 cv._registerMatType(Mat) โ”‚
โ”‚ 34 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
AttributeError: partially initialized module 'cv2' has no attribute '_registerMatType' (most likely due to a
circular import)

The above exception was the direct cause of the following exception:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ in :9 โ”‚
โ”‚ โ”‚
โ”‚ 6 from PIL import Image โ”‚
โ”‚ 7 โ”‚
โ”‚ 8 from diffusers import StableDiffusionPipeline โ”‚
โ”‚ โฑ 9 from optimum.intel import INCQuantizer, INCStableDiffusionPipeline โ”‚
โ”‚ 10 โ”‚
โ”‚ 11 #todo: check โ”‚
โ”‚ 12 #parameter โ”‚
โ”‚ in _handle_fromlist:1039 โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/transformers/utils/import_utils.py:1136 in getattr โ”‚
โ”‚ โ”‚
โ”‚ 1133 โ”‚ โ”‚ if name in self._modules: โ”‚
โ”‚ 1134 โ”‚ โ”‚ โ”‚ value = self._get_module(name) โ”‚
โ”‚ 1135 โ”‚ โ”‚ elif name in self._class_to_module.keys(): โ”‚
โ”‚ โฑ 1136 โ”‚ โ”‚ โ”‚ module = self._get_module(self._class_to_module[name]) โ”‚
โ”‚ 1137 โ”‚ โ”‚ โ”‚ value = getattr(module, name) โ”‚
โ”‚ 1138 โ”‚ โ”‚ else: โ”‚
โ”‚ 1139 โ”‚ โ”‚ โ”‚ raise AttributeError(f"module {self.name} has no attribute {name}") โ”‚
โ”‚ โ”‚
โ”‚ /usr/local/lib/python3.8/dist-packages/transformers/utils/import_utils.py:1148 in _get_module โ”‚
โ”‚ โ”‚
โ”‚ 1145 โ”‚ โ”‚ try: โ”‚
โ”‚ 1146 โ”‚ โ”‚ โ”‚ return importlib.import_module("." + module_name, self.name) โ”‚
โ”‚ 1147 โ”‚ โ”‚ except Exception as e: โ”‚
โ”‚ โฑ 1148 โ”‚ โ”‚ โ”‚ raise RuntimeError( โ”‚
โ”‚ 1149 โ”‚ โ”‚ โ”‚ โ”‚ f"Failed to import {self.name}.{module_name} because of the followin โ”‚
โ”‚ 1150 โ”‚ โ”‚ โ”‚ โ”‚ f" traceback):\n{e}" โ”‚
โ”‚ 1151 โ”‚ โ”‚ โ”‚ ) from e โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
RuntimeError: Failed to import optimum.intel.neural_compressor because of the following error (look up to see its
traceback):
partially initialized module 'cv2' has no attribute '_registerMatType' (most likely due to a circular import)

Hi @JiaojiaoYe1994,

Your issue seems related to opencv, this might help : opencv/opencv-python#591

Where you able to fix it on your side @JiaojiaoYe1994 ?

commented