Torch 2.0.0 is not compatible with anything I want to install

I’m running the following code:

!pip install tokenizers
!pip install torchdata

import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchtext.datasets import Multi30k

And I get the following error:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchvision 0.14.1+cu116 requires torch==1.13.1, but you have torch 2.0.0 which is incompatible.
torchtext 0.14.1 requires torch==1.13.1, but you have torch 2.0.0 which is incompatible.
torchaudio 0.13.1+cu116 requires torch==1.13.1, but you have torch 2.0.0 which is incompatible.
fastai 2.7.11 requires torch<1.14,>=1.7, but you have torch 2.0.0 which is incompatible.

Is this related to the release of PyTorch 2.0? If so, how can I fix this? I suppose I need to use torch 1.13.1 but I don’t know how.

Apparently, torchdata and torchvision is working with torch 2.0.0, however, it is not the case for torchtext (or at least I couldn’t figure it out).

If anyone else comes across the same issue, I suggest using torch 1.13.1 if you plan on working with torchtext.

Modifying my code like this solved the problem:

!pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 torchtext==0.14.1 fastai==2.7.11
!pip install tokenizers
!pip install torchdata==0.5.1

You can check which package is compatible with which torch version from github.

I hope the next version change goes smoother.

1 Like

Are you still running into the issue?
I just tried to install torchtext in the latest version and I get 0.15.1 as seen here:

>>> import torch
>>> import torchtext
>>> torch.__version__
'2.0.0+cu118'
>>> torchtext.__version__
'0.15.1+cpu'
1 Like

In the github page, the new 0.15.1 version was not listed, so that’s why I assumed torchtext wasn’t available to be used with torch 2.0.0.

I tried installing torchtext 0.15.1 and it works with torch 2.0.0 as you stated.

However, I believe my issue is with torchdata. When I do !pip install torchdata it installs the latest 0.6.0 version which has problems with the Multi30k dataset, which may be related to DataLoader.

I’m using the torchdata 0.5.1 now and it seems to be working.

Since torchdata 0.5.1 doesn’t work with torch 2.0.0, I assume new version of PyTorch is not reliable for people who wants to use torchdata. But for now, my issue is fixed, I hope they fix the problem with DataLoader in the new version of torchdata.

Did you already create a GitHub issue for this problem so that the code owners could track and fix it?

I created an issue just now

1 Like

Thanks.
When I use ‘pip3 install torch==1.13.1 torchdata==0.5.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117’,
it raised a conflict;
but when I install torchdata in the end, it run smoothly.
Anybody know the reason?

In the link you provided, there is no 0.5.1 version for torchdata here https://download.pytorch.org/whl/torchdata/, only 0.6.0 which works with the new torch v2.0.0.

I suggest you check all package versions and their dependencies because not all of them are compatible with one another. For example, if you want to use it, this works:

!pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 torchdata==0.5.1 torchtext==0.14.1

If you want to use these with cu117 however, I don’t know where to find the appropriate torchdata versions.

Oh I have realized my mistake, thank you very much!

Installing torchtext-0.15.2 sloved the problem.

I’m so sorry to bother you. My Torch version is the same as yours, and I’ve encountered the same issue. May I ask how you resolved it?

I did not run into the issue but was just helping our by installing the latest releases.