Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to run the deit colab notebook found here:

https://colab.research.google.com/github/facebookresearch/deit/blob/colab/notebooks/deit_inference.ipynb

but I'm running into an issue in the second cell, specifically the import timm line, which returns this:

ImportError: cannot import name 'container_abcs' from 'torch._six'

when I install torch==1.9.0 and torch-geometric, the old code has the errors.

here is my solution:

   TORCH_MAJOR = int(torch.__version__.split('.')[0])
   TORCH_MINOR = int(torch.__version__.split('.')[1])
   if TORCH_MAJOR == 0:
      import collections.abc as container_abcs
   else:
      from torch._six import container_abcs

change to:

    TORCH_MAJOR = int(torch.__version__.split('.')[0])
    TORCH_MINOR = int(torch.__version__.split('.')[1])
    if TORCH_MAJOR == 1 and TORCH_MINOR < 8:
        from torch._six import container_abcs,int_classes
    else:
        import collections.abc as container_abcs
        int_classes = int

I encountered this problem when I was working on PyTorch 1.12 version with a code base developed on PyTorch 1.6.

You should replace

from torch._six import container_abcs 
import container.abc as container_abcs 

as per this issue on GitHub.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.