因为1.8版本之后container_abcs就已经被移除了。
cannot import name 'container_abcs' from 'torch._six'
在使用一些开源代码的时候,可能会遇到该错误。
解决方法也很简单我们只需要给它换一个就行。
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