detectron2: ImportError: cannot import name 'is_fx_tracing' from 'torch.fx._symbolic_trace'

Error while running the Official Detectron2 Demo: yesterday I ran it and it was working fine. Today, it is giving me error. Run code cell # 3 from the top. Where importing libraries. It gives error after the comment # import some common detectron2 utilities Link to the Cell: https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=ZyAvNCJMmvFF It gives error on running the following line from detectron2 import model_zoo but if you comment above line, it gives same error on next line i.e., from detectron2.engine import DefaultPredictor

Error is ImportError: cannot import name 'is_fx_tracing' from 'torch.fx._symbolic_trace' (/usr/local/lib/python3.7/dist-packages/torch/fx/_symbolic_trace.py)

it is easily reproduceable as it is given by default notebook. Opened a fresh one from the link given on following page https://github.com/facebookresearch/detectron2 Still the same error. Someone maybe pushed something in last 24 hours that made it give this error.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 6
  • Comments: 17

Most upvoted comments

It seems like this issue was introduced with the latest commit (36a65a0907d90ed591479b2ebaa8b61cfa0b4ef0).

Specifying the previous commit hash from august 4th to install detectron2 fixed this issue for me. pip install git+https://github.com/facebookresearch/detectron2.git@5aeb252b194b93dc2879b4ac34bc51a31b5aee13

This is the problem of detecron2 version, I solve it by installing suitable version in https://github.com/facebookresearch/detectron2/releases

!!! You can temporary fix this issue on colab by:

  1. Open poolers.py source code image

  2. Comment line 10, 223->237 image image

  3. Restart runtime image

  4. Then run code ( but not run "!python -m pip install ‘git+https://github.com/facebookresearch/detectron2.git’ " again ).

Its work for me, but i think it just temporary solution.

@maziqueen79 I had the same error problem with this installation

!pip uninstall torch -y !pip uninstall torchvision -y !pip install torch==1.10.1+cu111 torchvision==0.11.2+cu111 -f https://download.pytorch.org/whl/torch_stable.html !python -m pip install ‘git+https://github.com/facebookresearch/detectron2.git’

And commenting the lines of poolers.py works for me and I’m training a maskrcnn model without problems Thanks