ImportError: Cannot load DGL C++ sparse library

Traceback (most recent call last):
File “”, line 2, in
import dgl.sparse as dglsp
File “/home/lixintao/anaconda3/envs/dgl/lib/python3.8/site-packages/dgl/sparse/”, line 43, in
File “/home/lixintao/anaconda3/envs/dgl/lib/python3.8/site-packages/dgl/sparse/”, line 40, in load_dgl_sparse
raise ImportError(“Cannot load DGL C++ sparse library”)
ImportError: Cannot load DGL C++ sparse library

dgl version:1.1.0+cu102
torch version:1.12.1+cu102
cuda version:11.1

I want to run HGNN using dgl.sparse,I have intsalled all the packages ,but when I run the code ,an issue above occured,can anyone tell me how to solve it?

DGL Sparse requires torch >=1.13.0. Could you try with latest DGL with torch 1.13.x or 2.0.x?

Okay,I 'll have a try

As my CUDA version is 11.1,the highest pytorch version I can install is 1.12.1,so I can’t install torch 1.13.x or 2.0.x.
And I can’t update my CUDA version,because I’m using server and I don’t have the right to update. Is there any other solution ?

you could try to build DGL from source with latest torch you have. Please refer to Install and Setup — DGL 1.1.2post1 documentation for the instructions. But I’m afraid build would fail.

Another option is docker. You could update the cuda driver, torch, DGL in the docker as you want.

Okay,I’ll try to use docker.Thanks