Colab Notebook: Cannot import name 'container_abcs' from 'torch._six'

Viewed 5862
3 Answers
  • Issue related to this error here:

Try a specific version of timm library:

!pip install timm==0.3.2

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

In my case it worked with

pip install timm==0.4.12
Related