ImportError: libcusparseLt.so.0: cannot open shared object file: No such file or directory

Atotem: <p>Hello,<br>
Recently I updated CUDA version to 12.2 in my machine (Ubuntu 22.04).</p>
<pre><code class="lang-auto">+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.104.05             Driver Version: 535.104.05   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4050 ...    On  | 00000000:01:00.0  On |                  N/A |
| N/A   37C    P8               1W /  60W |     21MiB /  6141MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      2031      G   /usr/bin/gnome-shell                          1MiB |
+---------------------------------------------------------------------------------------+
</code></pre>
<p>I installed pytorch in a conda virtual environment using the latest version:<br>
<code>conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch-nightly -c nvidia</code></p>
<p>And, when I try to run <code>import pytorch</code> I get the following error message:<br>
<code>ImportError: libcusparseLt.so.0: cannot open shared object file: No such file or directory</code></p>
<p>So, I checked checking inside <code>/usr/local/cuda</code> with <code>find -name libcusparse*</code> and I effectively don’t have that file.</p>
<pre><code class="lang-auto">./targets/x86_64-linux/lib/libcusparse.so.12.1.2.141
./targets/x86_64-linux/lib/libcusparse_static.a
./targets/x86_64-linux/lib/libcusparse.so
./targets/x86_64-linux/lib/stubs/libcusparse.so
./targets/x86_64-linux/lib/libcusparse.so.12
</code></pre>
<p>So my question is, should I install that file from the following url: <a href="https://developer.nvidia.com/cusparselt-downloads?target_os=Linux&amp;target_arch=x86_64&amp;Distribution=Ubuntu&amp;target_version=22.04&amp;target_type=deb_local" class="inline-onebox" rel="noopener nofollow ugc">cuSPARSELt Downloads | NVIDIA Developer</a> ? Or is this an issue from pytorch? I ask this because I have another conda environment where I can actually run <code>import torch</code> which I installed the 2023-09-25 by checking the list of conda revisions, without issues. However, if I run <code>torch.cuda.is_available()</code> I get <code>False</code>. Which is again weird because the first week of this month (October 2023) I didn’t have this issue. The only changes I remember are a package I installed via pip like pylabel. And I updated conda recently.</p>

Atotem: <p>Complementing even more, I just found another conda environment which has the following version of pytorch:<br>
<code>pytorch                   2.2.0.dev20230913 py3.8_cuda12.1_cudnn8.9.2_0    pytorch-nightly</code></p>
<p>Which I installed the 2023-09-13, and when I run:</p>
<pre><code class="lang-auto">import torch
torch.cuda.is_available()
</code></pre>
<p>I get <code>True</code>. What’s causing this issue?</p>

Atotem: <p>This week I did the same exercise and it’s working fine.</p>

AHMAD_WASEEM: <p>I guess you need to install libcudasparseLt. Use this link: <a href="https://developer.nvidia.com/cusparselt-downloads" rel="noopener nofollow ugc">https://developer.nvidia.com/cusparselt-downloads</a></p>

zenmixalot: <p>Installing cuda toolkit 11.7 fixed this for me.</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://developer.nvidia.com/cuda-11-7-0-download-archive">
  <header class="source">
      <img src="https://dirms4qsy6412.cloudfront.net/assets/favicon-81bff16cada05fcff11e5711f7e6212bdc2e0a32ee57cd640a8cf66c87a6cbe6.ico" class="site-icon" width="48" height="48">

      <a href="https://developer.nvidia.com/cuda-11-7-0-download-archive" target="_blank" rel="noopener nofollow ugc">NVIDIA Developer</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/362;"><img src="https://developer.download.nvidia.com/images/og-default.jpg" class="thumbnail" width="690" height="362"></div>

<h3><a href="https://developer.nvidia.com/cuda-11-7-0-download-archive" target="_blank" rel="noopener nofollow ugc">CUDA Toolkit 11.7 Downloads</a></h3>



  </article>

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

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


zrinaaa: <p>Hi! I have encountered this same issue for a while now, and i can not seem to get rid of it. i did try installing libcudasparseLt from the link provided but that does not work either. Could you ultimately get this issue to work?</p>

ptrblck: <p>Which PyTorch release are you using?</p>

ptrblck: <p>I cannot reproduce any issue using PyTorch <code>2.6.0</code> and see the right <code>libcusparseLt.so</code> is opened from the pip wheel during <code>import torch</code>:</p>
<pre><code class="lang-auto">LD_DEBUG=libs python -c "import torch"
...
calling init: /usr/local/lib/python3.12/dist-packages/torch/lib/../../cusparselt/lib/libcusparseLt.so.0
</code></pre>
<p>Your repo link points to an SSO so you might want to remove it.</p>