About the solution to the error cannot import name 'container_abcs' from 'torch._six' after upgrading pytorch1.9

Because container_abcs has been removed after version 1.8.

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

You may encounter this error when using some open source code.

The solution is also very simple, we just need to replace it.

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
else:
    import collections.abc as container_abcs

A super easy-to-use debugging APP,  go to the app store

Guess you like

Origin blog.csdn.net/qq_19313495/article/details/120361059