Torch 2.0.0 is not compatible with anything I want to install

Theo: <p>I’m running the following code:</p>
<pre><code class="lang-auto">!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
</code></pre>
<p>And I get the following error:</p>
<pre><code class="lang-auto">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&lt;1.14,&gt;=1.7, but you have torch 2.0.0 which is incompatible.
</code></pre>
<p>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.</p>

Theo: <p>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).</p>
<p>If anyone else comes across the same issue, I suggest using torch 1.13.1 if you plan on working with torchtext.</p>
<p>Modifying my code like this solved the problem:</p>
<pre><code class="lang-auto">!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
</code></pre>
<p>You can check which package is compatible with which torch version from github.</p>
<ul>
<li>Torchdata:    <a href="https://github.com/pytorch/data" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/data: A PyTorch repo for data loading and utilities to be shared by the PyTorch domain libraries.</a>
</li>
<li>Torchtext:     <a href="https://github.com/pytorch/text" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/text: Models, data loaders and abstractions for language processing, powered by PyTorch</a>
</li>
<li>Torchvision: <a href="https://github.com/pytorch/vision" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision</a>
</li>
</ul>
<p>I hope the next version change goes smoother.</p>

ptrblck: <p>Are you still running into the issue?<br>
I just tried to install <code>torchtext</code> in the latest version and I get <code>0.15.1</code> as seen here:</p>
<pre><code class="lang-python">&gt;&gt;&gt; import torch
&gt;&gt;&gt; import torchtext
&gt;&gt;&gt; torch.__version__
'2.0.0+cu118'
&gt;&gt;&gt; torchtext.__version__
'0.15.1+cpu'
</code></pre>

Theo: <p>In the github page, the new <code>0.15.1</code> version was not listed, so that’s why I assumed <code>torchtext</code> wasn’t available to be used with <code>torch 2.0.0</code>.</p>
<p>I tried installing <code>torchtext 0.15.1</code> and it works with <code>torch 2.0.0</code> as you stated.</p>
<p>However, I believe my issue is with <code>torchdata</code>. When I do <code>!pip install torchdata</code> it installs the latest <code>0.6.0</code> version which has problems with the Multi30k dataset, which may be related to DataLoader.</p>
<p>I’m using the <code>torchdata 0.5.1</code> now and it seems to be working.</p>
<p>Since <code>torchdata 0.5.1</code> doesn’t work with <code>torch 2.0.0</code>, I assume new version of PyTorch is not reliable for people who wants to use <code>torchdata</code>. But for now, my issue is fixed, I hope they fix the problem with DataLoader in the new version of <code>torchdata</code>.</p>

ptrblck: <aside class="quote no-group" data-username="Theo" data-post="4" data-topic="175067">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/t/a87d85/48.png" class="avatar"> Theo:</div>
<blockquote>
<p>it installs the latest <code>0.6.0</code> version which has problems with the Multi30k dataset, which may be related to DataLoader.</p>
</blockquote>
</aside>
<p>Did you already create a GitHub issue for this problem so that the code owners could track and fix it?</p>

Theo: <p>I created an issue just now</p>
<aside class="onebox githubissue" data-onebox-src="https://github.com/pytorch/data/issues/1093">
  <header class="source">

      <a href="https://github.com/pytorch/data/issues/1093" target="_blank" rel="noopener nofollow ugc">github.com/pytorch/data</a>
  </header>

  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewbox="0 0 14 16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/pytorch/data/issues/1093" target="_blank" rel="noopener nofollow ugc">NameError: name 'portalocker' is not defined</a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2023-03-16" data-time="23:44:30" data-timezone="UTC">11:44PM - 16 Mar 23 UTC</span>
      </div>


      <div class="user">
        <a href="https://github.com/afurkank" target="_blank" rel="noopener nofollow ugc">
          <img alt="afurkank" src="https://avatars.githubusercontent.com/u/62884181?v=4" class="onebox-avatar-inline" width="20" height="20">
          afurkank
        </a>
      </div>
    </div>

    <div class="labels">
    </div>
  </div>
</div>

  <div class="github-row">
    <p class="github-body-container">### 🐛 Describe the bug

When trying to create an iterator from Multi30k dataset <span class="show-more-container"><a href="" rel="noopener" class="show-more">…</a></span><span class="excerpt hidden">with the following code:
```
!pip install torch==2.0.0 torchtext==0.15.1
!pip install torchdata==0.6.0
import torch
import torchtext
from torchtext.datasets import Multi30k

SRC_LANGUAGE = 'de'
TGT_LANGUAGE = 'en'

train_iter = Multi30k(split='train', language_pair=(SRC_LANGUAGE, TGT_LANGUAGE))
```

I get the following error:
```
ModuleNotFoundError: Package 'portalocker' is required to be installed to use this datapipe. Please use 'pip install 'portalocker&gt;=2.0.0'' or 'conda install -c conda-forge 'portalocker&gt;=2/0.0' to install the package
```

I then installed the said package like this:
```!pip install 'portalocker&gt;=2.0.0'``` 

Which solved the issue. And when I tried to iterate over train_iter:
```
for i in train_iter:
    print("hello world")
```

I got this error:
```
NameError: name 'portalocker' is not defined
This exception is thrown by __iter__ of _MemoryCellIterDataPipe(remember_elements=1000, source_datapipe=_ChildDataPipe)
```

None of this happens with version 0.5.1 of torchdata.

### Versions

Collecting environment information...
PyTorch version: 2.0.0+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: 10.0.0-4ubuntu1 
CMake version: version 3.22.6
Libc version: glibc-2.31

Python version: 3.9.16 (main, Dec  7 2022, 01:11:51)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.10.147+-x86_64-with-glibc2.31
Is CUDA available: False
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.7.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.7.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.7.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.7.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.7.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.7.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.7.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   48 bits physical, 48 bits virtual
CPU(s):                          2
On-line CPU(s) list:             0,1
Thread(s) per core:              2
Core(s) per socket:              1
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      23
Model:                           49
Model name:                      AMD EPYC 7B12
Stepping:                        0
CPU MHz:                         2250.000
BogoMIPS:                        4500.00
Hypervisor vendor:               KVM
Virtualization type:             full
L1d cache:                       32 KiB
L1i cache:                       32 KiB
L2 cache:                        512 KiB
L3 cache:                        16 MiB
NUMA node0 CPU(s):               0,1
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Vulnerable
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1:        Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers
Vulnerability Spectre v2:        Vulnerable, IBPB: disabled, STIBP: disabled, PBRSB-eIBRS: Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext ssbd ibrs ibpb stibp vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 clzero xsaveerptr arat npt nrip_save umip rdpid

Versions of relevant libraries:
[pip3] numpy==1.22.4
[pip3] torch==2.0.0
[pip3] torchaudio==0.13.1+cu116
[pip3] torchdata==0.6.0
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.15.1
[pip3] torchvision==0.14.1+cu116
[pip3] triton==2.0.0
[conda] Could not collect</span></p>
  </div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


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

Theo: <p>In the link you provided, there is no 0.5.1 version for torchdata here <a href="https://download.pytorch.org/whl/torchdata/" rel="noopener nofollow ugc">https://download.pytorch.org/whl/torchdata/</a>, only 0.6.0 which works with the new torch v2.0.0.</p>
<p>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:</p>
<p>!pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 torchdata==0.5.1 torchtext==0.14.1</p>
<p>If you want to use these with cu117 however, I don’t know where to find the appropriate torchdata versions.</p>

peixin_xiao: <p>Oh I have realized my mistake, thank you very much!</p>

falmasri: <p>Installing torchtext-0.15.2 sloved the problem.</p>

min_zhou: <p>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?</p>

ptrblck: <p>I did not run into the issue but was just helping our by installing the latest releases.</p>

iqra: <p>ERROR: Could not find a version that satisfies the requirement torch==2.1.0 (from versions: 2.2.0 cpu, 2.2.1 cpu, 2.2.2 cpu, 2.3.0 cpu, 2.3.1 cpu, 2.4.0 cpu) ERROR: No matching distribution found for torch==2.1.0 anyony guide me</p>

ptrblck: <p>Which command are you trying to run using which Python version?</p>