Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix import container_abcs issue #1049

Merged
merged 5 commits into from
Feb 10, 2021
Merged

Conversation

ShoufaChen
Copy link
Contributor

Nightly PyTorch has removed container_abcs from torch._six.
pytorch/pytorch@58eb233#diff-b3c160475f0fbe8ad50310f92d3534172ba98203387a962b7dc8f4a23b15cf4dL35

Also fix #1048 and #1046

@ShoufaChen
Copy link
Contributor Author

ShoufaChen commented Feb 9, 2021

CC @mcarilli @seryilmaz @definitelynotmcarilli

Hi, would you mind having a review?

@mcarilli
Copy link
Contributor

mcarilli commented Feb 9, 2021

Apex is in maintenance mode at best. I'm not working on apex, but i guess this counts as "maintenance." I AM working to ensure all of apex's commonly used features have better support through Pytorch itself. I strongly recommend anyone still using apex amp or DDP to use torch.cuda.amp and torch.nn.parallel.DistributedDataParallel instead. torch.optim fused optimizers are also coming soon courtesy of @izdeby.

import collections.abc as container_abcs
else:
from torch._six import container_abcs
import collections.abc as container_abcs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep existing import for Pytorch 1.7 and earlier:

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion. I've updated it.

@dbonner
Copy link

dbonner commented Feb 10, 2021

Thanks @ShoufaChen and @mcarilli for such a prompt response.
I can confirm that your patch fixes the import isssue on my machines.
All the best,
Dan

@mcarilli mcarilli merged commit a78ccf0 into NVIDIA:master Feb 10, 2021
@ShoufaChen ShoufaChen deleted the fix-import branch February 11, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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