-
Notifications
You must be signed in to change notification settings - Fork 7k
Improve error message when incompatible torchvision / PyTorch are used #2148
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
Comments
Out of curiosity: does a list of compatible versions exist somewhere? |
Compatibility between PyTorch and torchvision versions is currently as follows:
So for nightlies, we could use the nightly date as a criteria for compatibility, although it should also work for users who are compiling torchvision from source (in which case, the compatibility constraints are much less restricted) I agree that this is not ideal and might be a bit hard to track, but until we manage to find a way to make the PyTorch ABI fixed / stable (probably not going to happen), this will maybe be the only way. I would love to hear other ideas though. |
@fmassa I've found that it is currently very difficult to determine which pairings of PyTorch and Torchvision are compatible. For example, a question that I've had a few times in the past is "given that I have some old version PyTorch #.#.# installed (that I can't upgrade), what is the newest Torchvision that I can install with it?". Currently this is actually not so easy to find out. This is particularly important for a project like PyTorch, since there are numerous reasons why you may not be able to upgrade (eg API changes, Python 2 support, CUDA version support).
This answer is somewhat unhelpful for two reasons:
|
I second this. Had to do this multiple times myself. If I'm not mistaken there is a one-to-one relation for the stable releases. If that is the case couldn't we put simple table or something similar somewhere? |
I agree that having a compatibility table would be a good start. But it would also help to raise informative error messages at runtime if the versions are incompatible. |
How about we simply look at the version of pytorch, and throw a warning when importing torchvision with an incompatible version of pytorch? |
This is a good start, but things get a bit more complicated with nightlies and when compiling from master. |
The official statement is fairly straightforward for releases, and we could make a table to keep track of which torchvision version was targeting which pytorch version. For releases, as I suggested above, we could also explicitly throw a warning when a different version is detected. For nightlies or master, I see those as "at your own risk" with minimal guarantees. I would not say more than what the statement says above in the readme.
I agree. I believe a table would help with that.
The official statement implicitly talks of exact version matches, and we can make that more clear. Making torchvision support minimal pytorch version is a much bigger burden, and outside the scope of what I understand this issue to be. @fmassa -- are you planning to extend the support of torchvision outside the official statement? AFAIK torchaudio and torchtext are not planning this.
Were users here having issues with nighltlies or master? Or when using conda/pip to install torchvision? Again, I see nightlies and master as "at your own risk" with minimal guarantees. torchvision should simply be compatible with the latest master at all time.
Incompatible versions can lead to failures in many unexpected ways, and detecting all of them can be tricky. Once we detect incompatible versions, what do we do? Do we stop the import? Do we return a warning? Or maybe we selectively disabling features that are not supported? Catching errors and throwing other ones could also obscure legitimate issues. Thoughts?
What does torchtext do? |
Speaking for myself, I'm only really concerned with the release versions available via conda/pip. I don't foresee a situation in which I'd personally need to figure out the PyTorch version compatibilities for old Torchvision nightly builds. |
No, we will only enforce to be compatible with latest release, if it ends up working with older releases (if compiled from source) that's a bonus, not a requirement.
My thinking was: import should not error. Users might not want to use C++ extensions, and the code should still hopefully work fine in most cases. But if the user calls into a C++ extension, then they should ideally get a good error message.
Fair point. One of the issues we currently have is that in order to support torchhub, we need to catch an error at import and not hard-fail. But this makes error messages down the road a bit worse IMO.
I was referring to a table like https://github.com/pytorch/text#installation
I agree, let's not overly complicate the problem. Having a compatibility matrix in the readme, and a better error message when running C++ ops that failed loading the |
I've went through the blog posts and release notes and compiled the following table:
|
Thanks a lot for compiling this list @pmeier !
For torchvision < 0.3.0, the compatibility matrix was much simpler, because we didn't have compiled C++ bits in torchvision. So I would say that for PyTorch <= 1.0.0, the corresponding version of torchvision doesn't really matter, but we could pin it to 0.2.2
Patch versions also are compatible with the latest PyTorch stable release at the time of the release. So 0.4.2 is compatible with PyTorch 1.3.1, while both 0.4.0 and 0.4.1 are compatible with PyTorch 1.3.0
Normally, whenever there was a new PyTorch release, we have also released a new (potentially minor) release of torchvision so that it is compatible. That was the case for 1.3.1, and PyTorch 1.4.1 is not really a release (probably a mistake while creating the release candidate version) |
Are you sure about that? This blog post suggests that With your comments the table now looks like this:
Is this correct now? If that is the case I'll send a PR adding it to the README. |
Thanks for gathering this information. At the very least, the "or newer" should be removed from the README, as the released packages on PyPI all have a |
A correction for the table: the torchvision 0.5.0 package on PyPI requires torch==1.4.0, and it looks like torch 1.4.1 and 1.4.2 don't exist. |
My bad, this is how I think the compatibility matrix should look like
|
Another related issue: currently if the torchvision extension failed to load, due to whatever reasons (including incompatible pytorch version), it will just silently ignore the exception: vision/torchvision/extension.py Lines 23 to 27 in cf534fd
and later, if a user attempts to use operators in the extension, uninformative error like |
@ppwwyyxx yes, that would be a good thing to do, but unfortunately IIRC torchscript doesn't support global values, so I'm not sure how we would be able to do it properly. Actually, thinking about it a bit more, maybe here is one possible solution: try:
_register_extensions()
def _has_extension():
return True
except (ImportError, OSError):
def _has_extension():
return False and then in the python implementations def nms(...):
if not _has_extension():
raise RuntimeError("torchvision not compiled with .....")
return torch.ops.torchvision.nms(...) That could work with torchscript I think. |
A number of users report errors on the C++ operators when they update either PyTorch or torchvision, see for example #1916, with errors such as
We should improve the error message and instead point out that their pytorch / torchvision versions are incompatible.
This will give a better user experience.
The text was updated successfully, but these errors were encountered: