Import Error for 'MetaPath2Vec'

How can I fix this import error:
ImportError: cannot import name ‘MetaPath2Vec’ from ‘dgl.nn.pytorch’ (C:\Users\USER\anaconda3\lib\site-packages\dgl\nn\pytorch_init_.py)

I updated the dgl by this command:
conda install -c dglteam dgl

my pytorch version: 1.13.0
my dgl version: 0.9.1

Hi @zara , DGL 0.9.1 does not have MetaPath2Vec, which will be available in DGL 1.0. A workaround to use it for now is to build the DGL master branch from source.

Thank you for your reply. I used source codes that were here:
https://docs.dgl.ai/en/latest/_modules/dgl/nn/pytorch/network_emb.html#MetaPath2Vec
but I have this Error:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat1 in method wrapper_addmm)

Actually I used cuda in my implementations and after I used metapath2vec source codes I faced that Error.
I changed the cpu device of this sorce code to cuda but it doesn’t work.

Did you run it on DGL 0.9.1?

yes, I ran it on DGL 0.9.1 and I faced that RuntimeError.

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat1 in method wrapper_addmm)

Actually I used cuda in my implementations and after I used metapath2vec source codes I faced that Error.
I changed the cpu device of this sorce code to cuda but it doesn’t work.

Are your model and graph on the same device?

when I want to put my graph on cuda, I faced this Error:
C:\Users\Administrator\dgl-0.5\src\runtime\c_runtime_api.cc:88: Check failed: allow_missing: Device API gpu is not enabled. Please install the cuda version of dgl.

I checked and cuda was available.

Please check this page to install DGL with corresponding CUDA version. You might need to manually uninstall the old version first.

thank you mufeili for your response.
unfortunately my cuda version is 11.7 and the link you sent doesn’t contain installing dgl with cuda version 11.7
Should I uninstall the cuda version 11.7 and install cuda version 11.6?
Can you help me and say how to do that?

You can install cuda 11.6 by installing the corresponding PyTorch version if needed.

I did it and I have another problem and i face cuda out of memory.

GPU 0 : Intel(R) UHD Graapics - (GPU Memory: 7.9 and Shared GPU memory: 7.9)

GPU 1 : NVIDIA GeForce RTX 3050 Ti Laptop GPU - (Dedicated GPU memory: 4.0 and GPU Memory: 11.9 and Shared GPU memory: 7.9)

I ran a code and I faced this error:

DGLError: [00:55:04] C:\Users\Administrator\dgl-0.5\src\runtime\cuda\cuda_device_api.cc:119: Check failed: e == cudaSuccess || e == cudaErrorCudartUnloading: CUDA: out of memory

I searched and find out my codes run on cuda : 0 (I didn’t tell in codes)

I search and see: GPU CUDA compute capability major version: 0

I think my codes run on GPU 0

How can I run my codes on GPU 1?

How to install cuda on GPU 1?

CUDA_VISIBLE_DEVICES=1 python xxx.py

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