RuntimeError: operator torchvision::nms does not exist

username: AidanGoldfarb
cooked: <p>To reproduce</p>
<pre><code class="lang-auto">pip install --pre torch torchvision torchaudio -i https://download.pytorch.org/whl/nightly/cu118
</code></pre>
<p>(taken from <a href="https://github.com/pytorch/benchmark" rel="noopener nofollow ugc">Pytorch Bench README</a>)</p>
<p>then</p>
<pre><code class="lang-auto">python -c "import torchvision"
</code></pre>
<hr>
<p>INFO</p>
<p>Python</p>
<pre><code class="lang-auto">Python 3.8.10
</code></pre>
<p>Torch:</p>
<pre><code class="lang-auto">2.2.0.dev20231129+cpu
</code></pre>
<p>pip show torchvision</p>
<pre><code class="lang-auto">Name: torchvision
Version: 0.17.0.dev20231129+cu118
Summary: image and video datasets and models for torch deep learning
Home-page: https://github.com/pytorch/vision
Author: PyTorch Core Team
Author-email: soumith@pytorch.org
License: BSD
Location: /data/agoldf6/mypy/lib/python3.8/site-packages
Requires: numpy, torch, pillow, requests
Required-by: x-clip, torchbench, torch-fidelity, timm, open-clip-torch, lpips, effdet, dalle2-pytorch, DALL-E, clip-anytorch
</code></pre>
<p>Full output:</p>
<pre><code class="lang-auto">Traceback (most recent call last):
  File "&lt;string&gt;", line 1, in &lt;module&gt;
  File "/data/agoldf6/mypy/lib/python3.8/site-packages/torchvision/__init__.py", line 6, in &lt;module&gt;
    from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
  File "/data/agoldf6/mypy/lib/python3.8/site-packages/torchvision/_meta_registrations.py", line 164, in &lt;module&gt;
    def meta_nms(dets, scores, iou_threshold):
  File "/data/agoldf6/mypy/lib/python3.8/site-packages/torch/library.py", line 439, in inner
    handle = entry.abstract_impl.register(func_to_register, source)
  File "/data/agoldf6/mypy/lib/python3.8/site-packages/torch/_library/abstract_impl.py", line 30, in register
    if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"):
RuntimeError: operator torchvision::nms does not exist
</code></pre>

username: ptrblck
cooked: <p>Your install command specifies <code>cu118</code> while you’ve installed the CPU-only binaries, so something failed. Make sure you have a single <code>torch</code> and <code>torchvision</code> installation with the same CUDA runtime dependencies.</p>

username: Abdelkareem_Elkhateb
cooked: <p>if i am working with bright cluster, and have the head node without cuda, this is where i right my code and then use slrum to submit it into the cluster which uses the GPU, but i get this error.<br>
how can i solve such a problem?</p>

username: ptrblck
cooked: <p>Neither the install commands nor the actual PyTorch runtime depends on a locally installed CUDA toolkit, so make sure you have installed compatible PyTorch and torchvision binaries with the same CUDA runtime dependencies.</p>

username: RylanSchaeffer
cooked: <p>I just created a new conda environment and ran PyTorch’s suggested conda installation command:</p>
<p><code>conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia</code></p>
<p>I then hit the error:</p>
<p><code>RuntimeError: operator torchvision::nms does not exist</code></p>
<p>I think something may have broken with the default conda installation</p>

username: RylanSchaeffer
cooked: <p><code>conda list</code> shows:</p>
<pre><code class="lang-auto">pytorch                   2.3.1           gpu_cuda118py311hc135f25_100  
pytorch-cuda              12.4                 hc786d27_7    pytorch
...
torchvision               0.18.1                py311_cpu    pytorch
</code></pre>
<p>The default Pytorch installation command seems to have installed a CPU-version of torchvision</p>
<p>Additional context:</p>
<pre><code class="lang-auto"> NVIDIA-SMI 550.54.14              Driver Version: 550.54.14      CUDA Version: 12.4     
</code></pre>

username: RylanSchaeffer
cooked: <aside class="onebox stackexchange" data-onebox-src="https://stackoverflow.com/questions/76376486/how-to-install-pytorch-with-cuda-support-using-conda">
  <header class="source">

      <a href="https://stackoverflow.com/questions/76376486/how-to-install-pytorch-with-cuda-support-using-conda" target="_blank" rel="noopener nofollow ugc">stackoverflow.com</a>
  </header>

  <article class="onebox-body">
      <a href="https://stackoverflow.com/users/13916049/anon" target="_blank" rel="noopener nofollow ugc">
    <img alt="Anon" src="https://www.gravatar.com/avatar/c9c28949cf1d6b57247c4758c8412591?s=256&amp;d=identicon&amp;r=PG&amp;f=y&amp;so-version=2" class="thumbnail onebox-avatar" width="256" height="256">
  </a>

<h4>
  <a href="https://stackoverflow.com/questions/76376486/how-to-install-pytorch-with-cuda-support-using-conda" target="_blank" rel="noopener nofollow ugc">How to install Pytorch with CUDA support using conda?</a>
</h4>

<div class="tags">
  <strong>pytorch, conda</strong>
</div>

<div class="date">
  asked by
  
  <a href="https://stackoverflow.com/users/13916049/anon" target="_blank" rel="noopener nofollow ugc">
    Anon
  </a>
  on <a href="https://stackoverflow.com/questions/76376486/how-to-install-pytorch-with-cuda-support-using-conda" target="_blank" rel="noopener nofollow ugc">06:50PM - 31 May 23 UTC</a>
</div>

  </article>

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

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

<p>This shows that the problem is with the conda installer.</p>

username: ptrblck
cooked: <p>No, I don’t think the answers on StackOverflow are correct since <code>conda</code> is not smart enough to check which NVIDIA driver is installed etc. Otherwise you would not have to specify the CUDA runtime version in the command.<br>
Your install command would install the latest PyTorch release (2.5.1) while 2.3.1 was installed so again something is broken in your env. I would recommend creating a new environment with a supported Python version (3.10-3.12) and reinstall it.<br>
Also note that <code>conda</code> binaries will be deprecated and won’t be released anymore starting with PyTorch 2.6.0.</p>

username: JuniorLambda
cooked: <p>Hello google travelers who have landed here!</p>
<p>I also got this error with conda when installing pytorch-cpu and torchvision-cpu.</p>
<p>Conda is limited to installing versions that are available as packages via the configured channels. You can see which versions are available by using <code>conda search &lt;package&gt;</code>.</p>
<p>pytorch-cpu and torchvision-cpu are packages available only via the conda-forge channel and only a limited selection of old versions for these packages is available there.</p>
<p>What you should do instead is to add the pytorch channel by using</p>
<pre data-code-wrap="bash"><code class="lang-bash"># conda config --add channels pytorch             
</code></pre>
<p>and install a suitable pytorch/torchvision package available through that channel. It’s an official channel that is kept up-to-date, and also offers a long list of older versions of pytorch and related packages, prepared for various versions of python.</p>

username: gatoniel
cooked: <p>In case you have to install additional packages also from conda-forge, you can define that <code>torchvision</code> is received from the pytorch channel by using the <code>::</code> notation introduced here: <a href="https://github.com/conda/conda/issues/5693#issuecomment-505579189" class="inline-onebox" rel="noopener nofollow ugc">Feature request: Specify channel in yaml file? · Issue #5693 · conda/conda · GitHub</a></p>
<p>i.e.:</p>
<pre><code class="lang-auto">  - pytorch::torchvision
</code></pre>

username: seyed_hosein_Alhosei
cooked: <p>hi i downloaded " torch-2.7.0.dev20250311+cu128" in pycharm terminal and installed Successfully but when i run Training Command for YOLOv8 , pycharm shows this error: <strong>“NotImplementedError: Could not run ‘torchvision::nms’ with arguments from the ‘CUDA’ backend.”</strong></p>

username: seyed_hosein_Alhosei
cooked: <p>i have a script for Load Training and Validation Data for yolov8 model in pycharm that when i run codes , pycharm shows this error: <strong>RuntimeError: operator torchvision::nms does not exist</strong><br>
How can I fix the error?</p>