What does `cuda version of dgl` mean in the error message Please install the cuda version of dgl

I have encountered the following error when I tried to run a python code that imports dgl.

torch version: 2.2.1

dgl version: 2.1.0 (Not used `dgl-cu*)

CUDA version: 12.2 (the result of nvidia-smi but not nvcc --version)

I have checked that dgl does not support CUDA 12.2 and does this error occur because of that? Or just because I have not installed the CUDA version of dgl? (I am not sure what is the difference between dgl and dgl-cu* packages, too. See the note below.)

I would appreciate it if you could help me or give me some advice. Thank you.

/home/usr/Programs/work/myvenv/lib/python3.10/site-packages/torch/cuda/__init__.py:628: UserWarning: Can't initialize NVML

  warnings.warn("Can't initialize NVML")

Traceback (most recent call last):

  File "/home/usr/Programs/work/src/train.py", line 188, in EvalEpoch

    sample_batched = {'g': sample_batched['g'].to('cuda:0'), 'e': sample_batched['e'].to('cuda:0'),

  File "/home/usr/Programs/work/myvenv/lib/python3.10/site-packages/dgl/heterograph.py", line 5714, in to

    ret._graph = self._graph.copy_to(utils.to_dgl_context(device))

  File "/home/usr/Programs/work/myvenv/lib/python3.10/site-packages/dgl/heterograph_index.py", line 255, in copy_to

    return _CAPI_DGLHeteroCopyTo(self, ctx.device_type, ctx.device_id)

  File "dgl/_ffi/_cython/./function.pxi", line 295, in dgl._ffi._cy3.core.FunctionBase.__call__

  File "dgl/_ffi/_cython/./function.pxi", line 227, in dgl._ffi._cy3.core.FuncCall

  File "dgl/_ffi/_cython/./function.pxi", line 217, in dgl._ffi._cy3.core.FuncCall3

dgl._ffi.base.DGLError: [23:12:37] /opt/dgl/src/runtime/c_runtime_api.cc:82: Check failed: allow_missing: Device API cuda is not enabled. Please install the cuda version of dgl.


I have also checked this discussion:

But I am wondering are there any versions of dgl that support CUDA 12.1? Is it enough to use dgl 2.1.0 or should I use something like dgl-cu12*?

DGL 2.1.0 does support cuda 12.1.

Are you using torch 2.2.1 + cu12.1? If yes, please install the corresponding cuda 12.1 version by referring to Deep Graph Library. If you install correctly, the output of pip list|grep dgl is like 2.1.0+cu121

1 Like

Dear Rhett-Ying

Thank you very much for your answer!
I have check pip list|grep dgl and the result was follows:

$ pip list|grep dgl
dgl                      2.1.0

I have also checked this for PyTorch:

$ pip list | grep torch
torch                    2.2.1
torchdata                0.7.1

It seems that something like cu12.1 or torch-cu12.1, or dgl-cu121 is not installed.
I have searched for these packages on PyPI, but could not find any of them, though I could find older version such as dgl-cu1**.

I appreciate it again if you could tell me how to get these libraries.

DGL cuda version are not hosted in PyPI. It’s hosted on our own, actually on aws s3. If you want to use pure CPU version, please install the pure CPU version of torch and DGL. If you want to use cuda121 version, please install the cuda121 CPU version of torch and DGL.

For DGL package, please refer to Deep Graph Library.

pip install  dgl -f https://data.dgl.ai/wheels/cu121/repo.html
1 Like

Dear Rhett-Ying,

I really appreciate your help!
By the command in your answer, I was able to install 2.1.0+cu121. I will also try the same for PyTorch and then run my code again.

Thank you.

Dear Rhett-Ying,

I am so sorry. I’ve tried this command many times, but always the dgl 2.0.0 is installed. I cannot download any cuda verision by this command. Are there any other ways to download dgl+cu121 wheel?

Thank you!

Dear Yuqqqw

I think one possibility is that you have already installed dgl. Then, no matter how you try to re-install (or changed version) by pip install dgl -f https://data.dgl.ai/wheels/cu121/repo.html, the install does not occur since the package is already installed.

To solve this, you need to uninstall the dgl package first by pip uninstall dgl and then re-install it by pip install dgl -f https://data.dgl.ai/wheels/cu121/repo.html.

Actually, I came across the same issue after pip install dgl -f https://data.dgl.ai/wheels/cu121/repo.html but it was successfully solved by uninstalling the package first.

I will apologize if this is not the case. If you have any further questions, please let me know.

1 Like

May I ask are you using Windows or Linux environment?

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