BUG: ImportError: cannot import name 'FakeQuantizeBase' from 'torch.quantization'
See original GitHub issueAfter your recent release, I got this error from my code. I can only use my code by downgrading fvcore version to previous one.
Error Traceback:
2021-10-15T09:46:49.0347680Z ==================================== ERRORS ====================================
2021-10-15T09:46:49.0350615Z [31m[1m________________________ ERROR collecting test session _________________________[0m
2021-10-15T09:46:49.0352801Z [1m[31m/usr/local/lib/python3.8/dist-packages/_pytest/config/__init__.py[0m:495: in _importconftest
2021-10-15T09:46:49.0358791Z return self._conftestpath2mod[key]
2021-10-15T09:46:49.0360317Z [1m[31mE KeyError: PosixPath('/app/cv_ner_detectron/tests/conftest.py')[0m
2021-10-15T09:46:49.0360877Z
2021-10-15T09:46:49.0362075Z [33mDuring handling of the above exception, another exception occurred:[0m
2021-10-15T09:46:49.0363832Z [1m[31m/usr/local/lib/python3.8/dist-packages/_pytest/config/__init__.py[0m:501: in _importconftest
2021-10-15T09:46:49.0364711Z mod = conftestpath.pyimport()
2021-10-15T09:46:49.0365834Z [1m[31m/usr/local/lib/python3.8/dist-packages/py/_path/local.py[0m:704: in pyimport
2021-10-15T09:46:49.0368988Z __import__(modname)
2021-10-15T09:46:49.0370340Z [1m[31m/usr/local/lib/python3.8/dist-packages/_pytest/assertion/rewrite.py[0m:152: in exec_module
2021-10-15T09:46:49.0372267Z exec(co, module.__dict__)
2021-10-15T09:46:49.0373441Z [1m[31mcv_ner_detectron/tests/conftest.py[0m:11: in <module>
2021-10-15T09:46:49.0377209Z from cv_ner_detectron.detectron.datamodels import CvNerExample
2021-10-15T09:46:49.0378686Z [1m[31mcv_ner_detectron/detectron/datamodels.py[0m:7: in <module>
2021-10-15T09:46:49.0380548Z from detectron2.structures import BoxMode
2021-10-15T09:46:49.0382497Z [1m[31m/usr/local/lib/python3.8/dist-packages/detectron2/structures/__init__.py[0m:6: in <module>
2021-10-15T09:46:49.0385934Z from .keypoints import Keypoints, heatmaps_to_keypoints
2021-10-15T09:46:49.0387443Z [1m[31m/usr/local/lib/python3.8/dist-packages/detectron2/structures/keypoints.py[0m:6: in <module>
2021-10-15T09:46:49.0389906Z from detectron2.layers import interpolate
2021-10-15T09:46:49.0391270Z [1m[31m/usr/local/lib/python3.8/dist-packages/detectron2/layers/__init__.py[0m:10: in <module>
2021-10-15T09:46:49.0397234Z from .blocks import CNNBlockBase, DepthwiseSeparableConv2d
2021-10-15T09:46:49.0402621Z [1m[31m/usr/local/lib/python3.8/dist-packages/detectron2/layers/blocks.py[0m:4: in <module>
2021-10-15T09:46:49.0406940Z import fvcore.nn.weight_init as weight_init
2021-10-15T09:46:49.0408469Z [1m[31m/usr/local/lib/python3.8/dist-packages/fvcore/nn/__init__.py[0m:2: in <module>
2021-10-15T09:46:49.0409904Z from .activation_count import ActivationCountAnalysis, activation_count
2021-10-15T09:46:49.0411437Z [1m[31m/usr/local/lib/python3.8/dist-packages/fvcore/nn/activation_count.py[0m:10: in <module>
2021-10-15T09:46:49.0414217Z from .jit_analysis import JitModelAnalysis
2021-10-15T09:46:49.0415640Z [1m[31m/usr/local/lib/python3.8/dist-packages/fvcore/nn/jit_analysis.py[0m:15: in <module>
2021-10-15T09:46:49.0417905Z from fvcore.common.checkpoint import _named_modules_with_dup
2021-10-15T09:46:49.0419295Z [1m[31m/usr/local/lib/python3.8/dist-packages/fvcore/common/checkpoint.py[0m:23: in <module>
2021-10-15T09:46:49.0422403Z from torch.quantization import ObserverBase, FakeQuantizeBase
2021-10-15T09:46:49.0424633Z [1m[31mE ImportError: cannot import name 'FakeQuantizeBase' from 'torch.quantization' (/usr/local/lib/python3.8/dist-packages/torch/quantization/__init__.py)[0m
2021-10-15T09:46:49.0425328Z
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Getting:- ImportError: cannot import name 'FakeQuantizeBase ...
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,...
Read more >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 distributed ... C2 or L != H * W: logger.warning("Error in loading absolute_pos_embed, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1
I guess that the problem is related to the last commit where torch.quantization is imported if the torch version is smaller than 1.11. However, that does not maintain the past behavior since the references to torch.quantization were replaced assuming that the import works (and before it was verified that the torch version is larger than 1.8).
+1 ! python -m pip install detectron2 -f
https://dl.fbaipublicfiles.com/detectron2/wheels/cu110/torch1.7/index.html
This is the pytorch version I am installing and still getting the error