question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
wangqixuncommented, Oct 21, 2021

pip install fvcore==0.1.5.post20210924

0reactions
meiling-fducommented, Oct 29, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot import name 'QuantStub' from 'torch.ao.quantization'
Hi I am new to pytorch. I encounter an issue when I run the below. Can someone assist ? from torchvision import datasets,...
Read more >
quantization/fake_quantize.py · neilisaac/torch - Gemfury
import torch from torch.nn import Module from .observer import ... class FakeQuantizeBase(ABC, Module): r""" Base fake quantize module Any fake quantize ...
Read more >
Cannot import name 'QuantStub' from 'torch.ao.quantization'
I was able to creaet a fastai 2.5.x / Python 3.9 conda env using: conda env create -n fastbook -c defaults python=3.9 conda...
Read more >
python/microsoft/unilm/dit/object_detection/ditod ...
... quantization, \ ObserverBase, FakeQuantizeBase from torch import ... embedding for Swin if state_dict.get(append_prefix('absolute_pos_embed')) is not ...
Read more >
cannot import name 'QuantStub' from 'torch.ao.quantization'
I had the same error. Reinstalling/Updating PyTorch fixed it.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found