Issues Fine-Tuning Mask R-CNN Using PyTorch Tutorial: Module Errors with Torch and Torchvision

239 views Asked by At

I've been following this PyTorch tutorial to fine-tune a Mask R-CNN model with my own dataset. On paper, it seems straightforward, but in practice, I've run into several issues with torch and torchvision.

Firstly, when I run my code, it seems that some modules are not being recognized. I've tried different recent versions of torch and even cloned the torch repository directly from GitHub. Despite this, I get an error like:

---> 16 if torch._running_with_deploy():
AttributeError: module 'torch' has no attribute '_running_with_deploy'

Secondly, I also cloned the torchvision repository from GitHub, hoping it would fix my issues. However, I still encounter errors, such as:

ImportError: cannot import name '_meta_registrations' from 'torchvision' (C:\Users\anaconda33\lib\site-packages\torchvision\__init__.py)

I've spent quite some time looking for solutions online, but nothing seems to really solve my issues. I'm at a bit of a loss and would really appreciate some help.

If anyone has faced these problems before or has advice on how to solve them, I'm all ears.

Thanks in advance!

What I've tried so far to resolve these issues:

  • Switched between multiple versions of torch and torchvision to see if compatibility was the issue.
  • Cloned both the torch and torchvision repositories directly from GitHub, thinking the latest code might solve the problem.
  • Checked my environment variables and paths to make sure Python was looking in the right places.
1

There are 1 answers

0
user2314737 On

I managed run the tutorial by installing the nightly build of pytorch (a note at the beginning of the tutorial mentions that >=0.16 or nightly is required). Here's the commands that I used:

!pip uninstall -y torch
!pip install --pre torch torchvision  --index-url https://download.pytorch.org/whl/nightly/cpu

The second pip command installs pytorch's nightly version and it was generated from https://pytorch.org/. There you can specify for what operating system, pytorch build, package manager, you want to generate the install command.

enter image description here