Skip to content
New issue

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

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

Already on GitHub? # to your account

Getting rid of torch._six (for future PyTorch versions) #486

Merged
merged 3 commits into from
Jul 5, 2022
Merged

Getting rid of torch._six (for future PyTorch versions) #486

merged 3 commits into from
Jul 5, 2022

Conversation

krshrimali
Copy link
Contributor

@krshrimali krshrimali commented Mar 6, 2022

Hi, I understand this library currently supports PyTorch version: 1.8.* but as we move along, and Open3D decided to support newer versions of PyTorch, it would help if we can get rid of torch._six completely.

Why is this needed?

So I faced this problem where I was testing a code which uses this library. The errors that I got were first related to torch._six.

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

Had to dig around to find, that torch._six had removed this from their library. Makes sense, since the community has started moving to Python 3.x versions.

Once these fixes were done, it gave me a clearer error that I was just using a newer version of PyTorch:

Exception: Version mismatch: Open3D needs PyTorch version 1.8.*, but version 1.10.2+cu113 is installed!

I think, it would be good if we get rid of torch._six completely, and use better alternatives, so that a user using inappropriate version of PyTorch gets a clear error instead of torch._six import errors.


This change is Reviewable

cc: @sanskar107

Comment on lines 1 to +2
import re
from torch._six import container_abcs, string_classes, int_classes
import collections
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is just to say more Pythonic. Low level imports on the top, and then external libraries like torch.

@sanskar107
Copy link
Collaborator

@krshrimali Thanks for the PR. Looks good to me. Can you fix the style issues ? (run make apply-style).

@krshrimali
Copy link
Contributor Author

Hi, @sanskar107 - Thanks for the review! Fixed the styling failures, hope it looks good now.

@sanskar107 sanskar107 merged commit 5148228 into isl-org:master Jul 5, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants