facebookresearch / fvcore

Collection of common code that's shared among different research projects in FAIR computer vision team.
Apache License 2.0
2.03k stars 229 forks source link

Getting:- ImportError: cannot import name 'FakeQuantizeBase' from 'torch.quantization' #89

Closed patrickn699 closed 3 years ago

patrickn699 commented 3 years ago

Hey, I am using torch version 1.7.1 CPU and detectron2 along with torch 1.7 but when I used it through my own package, I started getting this error. Please tell me how should I fix this?

ImportError                               Traceback (most recent call last)
<ipython-input-4-d3af5af0e43a> in <module>()
----> 1 from INPR import inpr
      2 import matplotlib.pyplot as plt
      3 get_ipython().magic('matplotlib inline')

4 frames
/usr/local/lib/python3.7/dist-packages/INPR/inpr.py in <module>()
      4 from PIL import Image
      5 import numpy as np
----> 6 from .utils import Load_model
      7 from .get_num_plate import get_number_plate
      8 from .get_details import fetch

/usr/local/lib/python3.7/dist-packages/INPR/utils.py in <module>()
----> 1 from detectron2.engine import DefaultPredictor
      2 from detectron2.data import MetadataCatalog
      3 from detectron2.config import get_cfg
      4 from detectron2.utils.visualizer import ColorMode, Visualizer
      5 from detectron2 import model_zoo

/usr/local/lib/python3.7/dist-packages/detectron2/engine/__init__.py in <module>()
      9 # prefer to let hooks and defaults live in separate namespaces (therefore not in __all__)
     10 # but still make them available here
---> 11 from .hooks import *
     12 from .defaults import *

/usr/local/lib/python3.7/dist-packages/detectron2/engine/hooks.py in <module>()
     11 from collections import Counter
     12 import torch
---> 13 from fvcore.common.checkpoint import PeriodicCheckpointer as _PeriodicCheckpointer
     14 from fvcore.common.param_scheduler import ParamScheduler
     15 from fvcore.common.timer import Timer

/usr/local/lib/python3.7/dist-packages/fvcore/common/checkpoint.py in <module>()
     21 else:
     22     from torch import quantization
---> 23     from torch.quantization import ObserverBase, FakeQuantizeBase
     24 
     25 __all__ = ["Checkpointer", "PeriodicCheckpointer"]

ImportError: cannot import name 'FakeQuantizeBase' from 'torch.quantization' (/usr/local/lib/python3.7/dist-packages/torch/quantization/__init__.py)
ningbende commented 3 years ago

I get the same error

ningbende commented 3 years ago

fix the error by revert current version

wangqixun commented 3 years ago

pip install fvcore==0.1.5.post20210924

ppwwyyxx commented 3 years ago

Duplicate of #87

meiling-fdu commented 3 years ago

you can upgrade the pytorch into version 1.8 and the problem will be solved.