Device API cuda is not enabled for Python 3.11 and CUDA 12.1

I am using Python 3.11 with torch 2.2.1+cu121 on Windows 10. I have installed dgl using pip install dgl -f https://data.dgl.ai/wheels/cu121/repo.html as recommended on this page.

When running python -c "import dgl; dgl.graph([]).to('cuda')" I get the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\me\proj\venv\Lib\site-packages\dgl\heterograph.py", line 5714, in to
    ret._graph = self._graph.copy_to(utils.to_dgl_context(device))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\proj\venv\Lib\site-packages\dgl\heterograph_index.py", line 255, in copy_to
    return _CAPI_DGLHeteroCopyTo(self, ctx.device_type, ctx.device_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\proj\venv\Lib\site-packages\dgl\_ffi\_ctypes\function.py", line 212, in __call__
    check_call(
  File "C:\Users\me\proj\venv\Lib\site-packages\dgl\_ffi\base.py", line 70, in check_call
    raise DGLError(py_str(_LIB.DGLGetLastError()))
dgl._ffi.base.DGLError: [13:28:36] C:\Users\peizhou\workspace\DGL_scripts\release\win-64\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 think that dgl has not installed properly with the above command, because I don’t see a cuda version in the installed version. Running pip list | grep dgl I get

dgl                           2.0.0
dglgo                         0.0.2
dgllife                       0.3.2

Any idea how I can install it properly?

I managed to install it properly with conda but not pip.

You’re right. wheel package for Windows is not updated onto the web page. @peizhou001 Please fix it.

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