Can't import import dgl with these setting

I can’t import dgl.

dgl 2.1.0+cu121
dglgo 0.0.2
(.mvenvl) root@MSI:/home/second_trial/linevd# pip list | grep torch
pytorch-lightning 2.2.0.post0
torch 2.1.1+cu121
torch_geometric 2.5.1
torch-scatter 2.1.2
torch-tb-profiler 0.4.3
torchaudio 2.1.1+cu121
torchdata 0.7.1
torchinfo 1.8.0
torchmetrics 1.3.1
torchsummary 1.5.1
torchtext 0.17.0
torchvision 0.16.1+cu121
tsne-torch 1.0.1
(.mvenvl) root@MSI:/home/second_trial/linevd# python3
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import dgl
Traceback (most recent call last):
File “”, line 1, in
File “/home/second_trial/linevd/.mvenvl/lib/python3.11/site-packages/dgl/”, line 14, in
from .backend import backend_name, load_backend # usort: skip
File “/home/second_trial/linevd/.mvenvl/lib/python3.11/site-packages/dgl/backend/”, line 122, in
File “/home/second_trial/linevd/.mvenvl/lib/python3.11/site-packages/dgl/backend/”, line 51, in load_backend
from …_ffi.base import load_tensor_adapter # imports DGL C library
File “/home/second_trial/linevd/.mvenvl/lib/python3.11/site-packages/dgl/_ffi/”, line 50, in
_LIB, _LIB_NAME, _DIR_NAME = _load_lib()
File “/home/second_trial/linevd/.mvenvl/lib/python3.11/site-packages/dgl/_ffi/”, line 39, in _load_lib
lib = ctypes.CDLL(lib_path[0])
File “/usr/lib/python3.11/ctypes/”, line 376, in init
self._handle = _dlopen(self._name, mode)
OSError: cannot open shared object file: No such file or directory

seems CUDA12.1 is not installed correctly or cannot be found. Could you try to verify with torch: `python3 -c “import torch;print(torch.cuda.is_available())”?

I did it and here are the answers:

Screenshot 2024-01-04 123309

I have same problem, but the torch is False, what should I do please, advice me, as the torch and the cuda and the dgl have cuda 12.1

Is there any GPU on your machine? Could you try to install pure CPU version of torch and DGL?

Could you try to call cuda related API with torch such as move tensor to cuda device?

And check if exists on your cuda lib path like below(on my Linux machine):

/usr/local/cuda/lib64/ ->

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.