Pytorch and Pytorchvision Compatibility in a Stable Diffusion

Caleb_Hill: <p>Thanks in advance for any help. I’m using Ubuntu 22.04 for this.</p>
<p>The error I’m getting is Couldn’t load custom C++ ops. This can happen if your PyTorch and torchvision versions are incompatible, or if you had errors while compiling torchvision from source. For further information on the compatible versions, check <a href="https://github.com/pytorch/vision#installation" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision</a> for the compatibility matrix.</p>
<p>Been trying to fix this for a couple of days with no luck.</p>
<p>Torch is 3.1.2+Cuda12.1<br>
Torchvision is 0.16.2+Cuda12.1<br>
Python is 3.10.12</p>
<p>Compatibility Matrix shows this should work. Nvidia Drivers:</p>
<p>NVRM version: NVIDIA UNIX x86_64 Kernel Module  535.154.05  Thu Dec 28 15:37:48 UTC 2023<br>
GCC version:  gcc version 12.3.0 (Ubuntu 12.3.0-1ubuntu1~22.04)</p>
<p>Is there other information needed to help solve this? I’m relatively new to all of this.</p>

ptrblck: <p>Could you describe which custom C++ ops you are trying to use and ideally post a minimal and executable code snippet to reproduce the issue?</p>
<aside class="quote no-group" data-username="Caleb_Hill" data-post="1" data-topic="196443">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/caleb_hill/48/67392_2.png" class="avatar"> Caleb_Hill:</div>
<blockquote>
<p>Torch is 3.1.2+Cuda12.1</p>
</blockquote>
</aside>
<p>You might mean <code>2.1.2+cu121</code>.</p>
<aside class="quote no-group" data-username="Caleb_Hill" data-post="1" data-topic="196443">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/caleb_hill/48/67392_2.png" class="avatar"> Caleb_Hill:</div>
<blockquote>
<p>Compatibility Matrix shows this should work. Nvidia Drivers:</p>
</blockquote>
</aside>
<p>I don’t see any CUDA/NVIDIA driver issue in the error message but a potential version mismatch between PyTorch and torchvision.</p>

Caleb_Hill: <p>Thanks for the responding, sorry for taking so long to get back, was on vacation.</p>
<p>I’m pretty new to all of this, so I’m sure I won’t answer your question properly, but I do think I found the problem, I just don’t know how to fix it. I’m trying to run Automatic 1111 (stable diffusion) and I believe I’ve installed it in a virtual environment (at least I think that’s what venv means). The torch and torchvision models in the venv folder I’ve discovered are incompatible. I have torchvision 0.15.2+cu118 and torch is 2.1.2+cu121, so I’m hoping this is my problem.</p>
<p>I think what I did is install the correct versions of the cuda, torch and torchvision inside Ubuntu, but didn’t realize I needed the correct ones in this virtual environment. Before I screw something up, could you maybe point me in the right direction for updating everything inside this virtual environment, providing you think this is my actual problem?</p>
<p>Thank you!</p>

ptrblck: <aside class="quote no-group" data-username="Caleb_Hill" data-post="3" data-topic="196443">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/caleb_hill/48/67392_2.png" class="avatar"> Caleb_Hill:</div>
<blockquote>
<p>install the correct versions of the cuda, torch and torchvision inside Ubuntu,</p>
</blockquote>
</aside>
<p>You don’t need to install a CUDA toolkit unless you want to build a custom CUDA extension or PyTorch from source.<br>
However, it’s still unclear if that’s the case.</p>
<p>If you want to install matching <code>torch</code> and <code>torchvision</code> versions, use the install commands from <a href="https://pytorch.org/get-started/locally/">here</a>.</p>

Caleb_Hill: <p>Got it! Problem is fixed. Thank you so much!</p>