facebookresearch/d2go

cannot import name 'get_fbgemm_backend_config' from 'torch.ao.quantization.backend_config'

Morpheushealer73 opened this issue ยท 7 comments

Hi, I'm currently installing D2go on Google Colab without CPU since Colab does not have conda and I'm getting the following Error

Instructions To Reproduce the ๐Ÿ› Bug:

  1. Full runnable code or full changes you made:
!pip install pyyaml
!pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
!pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
!python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
!python -m pip install 'git+https://github.com/facebookresearch/mobile-vision.git'
!git clone https://github.com/facebookresearch/d2go
!cd d2go && python -m pip install .

from d2go.model_zoo import model_zoo
model = model_zoo.get('faster_rcnn_fbnetv3a_C4.yaml', trained=True)

  1. What exact command you run:

from d2go.model_zoo import model_zoo

  1. Full logs or other relevant observations:
/usr/local/lib/python3.8/dist-packages/caffe2/__init__.py:5: UserWarning: Caffe2 support is not fully enabled in this PyTorch build. Please enable Caffe2 by building PyTorch from source with `BUILD_CAFFE2=1` flag.
  warnings.warn("Caffe2 support is not fully enabled in this PyTorch build. "
/usr/local/lib/python3.8/dist-packages/caffe2/proto/__init__.py:17: UserWarning: Caffe2 support is not enabled in this PyTorch build. Please enable Caffe2 by building PyTorch from source with `BUILD_CAFFE2=1` flag.
  warnings.warn('Caffe2 support is not enabled in this PyTorch build. '
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[<ipython-input-3-ffdbfe040df2>](https://localhost:8080/#) in <module>
----> 1 from d2go.model_zoo import model_zoo
      2 model = model_zoo.get('faster_rcnn_fbnetv3a_C4.yaml', trained=True)

7 frames
[/usr/local/lib/python3.8/dist-packages/d2go/__init__.py](https://localhost:8080/#) in <module>
     13 
     14 if not skip_initialization:
---> 15     initialize_all()

[/usr/local/lib/python3.8/dist-packages/d2go/initializer.py](https://localhost:8080/#) in initialize_all(boostrap_registries)
     14     _INITIALIZED = True
     15 
---> 16     _initialize_all(boostrap_registries=boostrap_registries)
     17 
     18 

[/usr/local/lib/python3.8/dist-packages/d2go/initializer.py](https://localhost:8080/#) in _initialize_all(boostrap_registries)
     21     _register_builtin_datasets()
     22 
---> 23     _populate_registries()
     24     if boostrap_registries:
     25         bootstrap_registries(enable_cache=True, catch_exception=True)

[/usr/local/lib/python3.8/dist-packages/d2go/initializer.py](https://localhost:8080/#) in _populate_registries()
     49     from d2go import optimizer  # noqa
     50     from d2go.data import dataset_mappers  # noqa
---> 51     from d2go.modeling.backbone import fbnet_v2  # noqa
     52 
     53 

[/usr/local/lib/python3.8/dist-packages/d2go/modeling/__init__.py](https://localhost:8080/#) in <module>
      4 
      5 # NOTE: making necessary imports to register with Registery
----> 6 from . import backbone, meta_arch, modeldef  # noqa  # noqa  # noqa

[/usr/local/lib/python3.8/dist-packages/d2go/modeling/meta_arch/__init__.py](https://localhost:8080/#) in <module>
      4 # NOTE: making necessary imports to register with Registry
      5 # @fb-only: from . import fb  # isort:skip  # noqa
----> 6 from . import fcos, panoptic_fpn, rcnn, retinanet, semantic_seg  # noqa

[/usr/local/lib/python3.8/dist-packages/d2go/modeling/meta_arch/rcnn.py](https://localhost:8080/#) in <module>
     28 from detectron2.utils.registry import Registry
     29 from mobile_cv.arch.utils import fuse_utils
---> 30 from mobile_cv.arch.utils.quantize_utils import (
     31     QuantWrapper,
     32     wrap_non_quant_group_norm,

[/usr/local/lib/python3.8/dist-packages/mobile_cv/arch/utils/quantize_utils.py](https://localhost:8080/#) in <module>
     13 import torch.nn as nn
     14 from mobile_cv.arch.layers import NaiveSyncBatchNorm
---> 15 from torch.ao.quantization.backend_config import (
     16     get_fbgemm_backend_config,
     17     get_native_backend_config,

ImportError: cannot import name 'get_fbgemm_backend_config' from 'torch.ao.quantization.backend_config' (/usr/local/lib/python3.8/dist-packages/torch/ao/quantization/backend_config/__init__.py)
  1. please simplify the steps as much as possible so they do not require additional resources to run, such as a private dataset.

Run the code using Google Colab with CPU

Expected behavior:

successful import of from d2go.model_zoo import model_zoo

If there are no obvious error in "what you observed" provided above,
please tell us the expected behavior.

Is there any updated google colab notebooks for D2go that I could use? that would be a great help

Solved this

@Morpheushealer73
Hi,
How did u solved that issue?

/home/sa/.conda/envs/test/lib/python3.9/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: libtorch_cuda_cu.so: cannot open shared object file: No such file or directory warn(f"Failed to load image Python extension: {e}") /home/sa/.conda/envs/test/lib/python3.9/site-packages/caffe2/__init__.py:5: UserWarning: Caffe2 support is not fully enabled in this PyTorch build. Please enable Caffe2 by building PyTorch from source with BUILD_CAFFE2=1flag. warnings.warn("Caffe2 support is not fully enabled in this PyTorch build. " /home/sa/.conda/envs/test/lib/python3.9/site-packages/caffe2/proto/__init__.py:17: UserWarning: Caffe2 support is not enabled in this PyTorch build. Please enable Caffe2 by building PyTorch from source withBUILD_CAFFE2=1 flag. warnings.warn('Caffe2 support is not enabled in this PyTorch build. ' Traceback (most recent call last): File "/mnt/c/Users/Lenovo/Desktop/linux/github/d2go/model_train.py", line 23, in <module> from d2go.model_zoo import model_zoo File "/mnt/c/Users/Lenovo/Desktop/linux/github/d2go/d2go/__init__.py", line 15, in <module> initialize_all() File "/mnt/c/Users/Lenovo/Desktop/linux/github/d2go/d2go/initializer.py", line 16, in initialize_all _initialize_all(boostrap_registries=boostrap_registries) File "/mnt/c/Users/Lenovo/Desktop/linux/github/d2go/d2go/initializer.py", line 23, in _initialize_all _populate_registries() File "/mnt/c/Users/Lenovo/Desktop/linux/github/d2go/d2go/initializer.py", line 51, in _populate_registries from d2go.modeling.backbone import fbnet_v2 # noqa File "/mnt/c/Users/Lenovo/Desktop/linux/github/d2go/d2go/modeling/__init__.py", line 6, in <module> from . import backbone, meta_arch, modeldef # noqa # noqa # noqa File "/mnt/c/Users/Lenovo/Desktop/linux/github/d2go/d2go/modeling/meta_arch/__init__.py", line 6, in <module> from . import fcos, panoptic_fpn, rcnn, retinanet, semantic_seg # noqa File "/mnt/c/Users/Lenovo/Desktop/linux/github/d2go/d2go/modeling/meta_arch/rcnn.py", line 30, in <module> from mobile_cv.arch.utils.quantize_utils import ( File "/home/sa/.conda/envs/test/lib/python3.9/site-packages/mobile_cv/arch/utils/quantize_utils.py", line 15, in <module> from torch.ao.quantization.backend_config import ( ImportError: cannot import name 'get_fbgemm_backend_config' from 'torch.ao.quantization.backend_config' (/home/sa/.conda/envs/test/lib/python3.9/site-packages/torch/ao/quantization/backend_config/__init__.py)

dipu0 commented

Solved this

can you please share with us.. facing same problem!

@Chiffon95 , @dipu0 I solved this issue by experimenting with ways to install D2go in colab because I deduced that this may be an installation issue with the things I installed above

Here's the latest notebook I made
https://colab.research.google.com/drive/1qyH2tvIllOHEo2i0ytM1UkHFd_iFcYiq?usp=sharing

dipu0 commented

@Chiffon95 , @dipu0 I solved this issue by experimenting with ways to install D2go in colab because I deduced that this may be an installation issue with the things I installed above

Here's the latest notebook I made https://colab.research.google.com/drive/1qyH2tvIllOHEo2i0ytM1UkHFd_iFcYiq?usp=sharing

thank you so much for sharing your notebook. i was able to run training cell by comment outing the error line(which is 16) let you now after finishing training.

Did you able to run android app ??

@Chiffon95 , @dipu0 I solved this issue by experimenting with ways to install D2go in colab because I deduced that this may be an installation issue with the things I installed above
Here's the latest notebook I made https://colab.research.google.com/drive/1qyH2tvIllOHEo2i0ytM1UkHFd_iFcYiq?usp=sharing

thank you so much for sharing your notebook. i was able to run training cell by comment outing the error line(which is 16) let you now after finishing training.

Did you able to run android app ??

Yes I did run an android app. Although we used flutter for it and modified tsubauaaa's repository
https://github.com/tsubauaaa/flutter_d2go

We had a problem with the repo's pytorch version(Flutter d2go's pytorch version is outdated) so you just need to change it accordingly for the d2go model to work in the app.