Torch_sparse cannot find cuda lib file from pytorch

c-earth: <p>I am trying to reproduce a previous work that used pytorch 1.4.0+cu100, and torch_sparse 0.6.1. However, after I run the model, the error message</p>
<p>OSError: libcusparse.so.10.0: cannot open shared object file: No such file or directory</p>
<p>is produced under one of torch_sparse function. I thought that pytorch is shipped with cuda dependencies, or is it not true for the older pytorch versions. So, I’m not sure what is the problem with my set up.</p>

ptrblck: <aside class="quote no-group" data-username="c-earth" data-post="1" data-topic="215733">
<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/c-earth/48/72657_2.png" class="avatar"> c-earth:</div>
<blockquote>
<p>OSError: libcusparse.so.10.0: cannot open shared object file: No such file or directory</p>
</blockquote>
</aside>
<p>Which CUDA runtime version is used in the <code>torch_sparse</code> build as it seems it might not be compatible with the ones shipped with PyTorch 1.4?</p>

c-earth: <p>I’m not sure how to check the CUDA runtime used. However, as per the instruction from the project (<a href="https://github.com/gomes-lab/Mat2Spec" class="inline-onebox" rel="noopener nofollow ugc">GitHub - gomes-lab/Mat2Spec</a>) I want to reproduce, I used the wheel file <a href="https://data.pyg.org/whl/torch-1.4.0/torch_sparse-0.6.1%2Bcu100-cp38-cp38-linux_x86_64.whl" rel="noopener nofollow ugc">https://data.pyg.org/whl/torch-1.4.0/torch_sparse-0.6.1%2Bcu100-cp38-cp38-linux_x86_64.whl</a> to install torch_sparse which should be CUDA 10.0?</p>

ptrblck: <p>I don’t know if <code>torch_sparse</code> depends on a locally installed CUDA toolkit, but installing the version you’ve mentioned together with <code>torch==1.4.0+cu101</code> fails directly with:</p>
<pre data-code-wrap="python"><code class="lang-python">python -c "import torch; import torch_sparse"
...
OSError: libcudart.so.10.0: cannot open shared object file: No such file or directory
</code></pre>
<p>Pointing to a missing <code>libcudart.so</code>.<br>
The PyTorch binaries ship with their own CUDA runtime lib as:</p>
<pre data-code-wrap="python"><code class="lang-python">.../site-packages/torch/lib/libcudart-1b201d85.so.10.1
</code></pre>
<p>adding the SHA value into its name to avoid conflicts during lazy loading.<br>
Since <code>torch_sparse</code> tries to load <code>libcudart.so</code> directly and does not ship with it:</p>
<pre data-code-wrap="python"><code class="lang-python">ls .../site-packages/torch_sparse
__init__.py  _convert.so  _metis.so  _saint.so  _spspmm.so   add.py  coalesce.py  diag.py  index_select.py   matmul.py  mul.py     permute.py  rw.py     select.py  spspmm.py   tensor.py     utils.py
__pycache__  _diag.so     _rw.so     _spmm.so   _version.so  cat.py  convert.py   eye.py   masked_select.py  metis.py   narrow.py  reduce.py   saint.py  spmm.py    storage.py  transpose.py
</code></pre>
<p>I assume a locally installed CUDA toolkit was needed in this older release.</p>

c-earth: <p>Thanks for your answer. Would there be any conflict if I install CUDA toolkit for 10.0 along side 11.8 in my local machine? since most of my projects use 11.8.</p>

ptrblck: <p>No, you can install multiple CUDA toolkits locally and can create the <code>/usr/local/cuda</code> symlink to the version you want to use.</p>