ImportError: cannot open shared object file: No such file or directory

Recently I updated CUDA version to 12.2 in my machine (Ubuntu 22.04).

| 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 |

I installed pytorch in a conda virtual environment using the latest version:
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch-nightly -c nvidia

And, when I try to run import pytorch I get the following error message:
ImportError: cannot open shared object file: No such file or directory

So, I checked checking inside /usr/local/cuda with find -name libcusparse* and I effectively don’t have that file.


So my question is, should I install that file from the following url: cuSPARSELt Downloads | NVIDIA Developer ? Or is this an issue from pytorch? I ask this because I have another conda environment where I can actually run import torch which I installed the 2023-09-25 by checking the list of conda revisions, without issues. However, if I run torch.cuda.is_available() I get False. 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.

Complementing even more, I just found another conda environment which has the following version of pytorch:
pytorch 2.2.0.dev20230913 py3.8_cuda12.1_cudnn8.9.2_0 pytorch-nightly

Which I installed the 2023-09-13, and when I run:

import torch

I get True. What’s causing this issue?

This week I did the same exercise and it’s working fine.