Device API gpu is not enabled

I am having issues making DGL work with CUDA, this is my current setup:

CUDA Version: 10.2
dgl==0.4.3.post2
dgl-cu102==0.4.3.post2

Cuda works correctly (I use it with both Keras and Torch):

>>> torch.cuda.is_available()
True
>>> torch.device('cuda:0')
device(type='cuda', index=0)
>>> torch.zeros(1).cuda()
tensor([0.], device='cuda:0')

But of course when I run:
>>> g.to(th.device(device)

I get:

DGLError: [17:03:22] /opt/dgl/src/runtime/c_runtime_api.cc:87: Check failed: allow_missing: Device API gpu is not enabled. Please install the cuda version of dgl.

So I tried to install and compile DGL from sources (enabling CUDA with CMAKE) but the result doesn’t change. What am I missing?

Thank you!

Can you first try uninstalling DGL and then reinstalling GPU enabled DGL? It’s possible that you have multiple versions of DGL installed and the one you import is actually a version without GPU support. You can verify the success of uninstalling DGL by failing to import dgl.

A big thanks @mufeili (as usual ;)) I solved it with your advice. Despite uninstalling the manually compiled copy and the one installed via pip one version of the package was still there.

For any future person coming here with the same problem (uninstalling DLG and still finding the package to be available) just print its path:

python3 -c 'import dgl; print(dgl.__path__)'

and remove it.

1 Like

Awesome! Glad it helps :slight_smile: