mims-harvard / TxGNN

TxGNN: Zero-shot prediction of therapeutic use with geometric deep learning and clinician centered design
https://zitniklab.hms.harvard.edu/projects/TxGNN
MIT License
113 stars 27 forks source link

Empty heterograph is not allowed. #6

Open prathameshk opened 6 months ago

prathameshk commented 6 months ago

When I am trying to load the pretrained graph then I get following error.

TxGNN.load_pretrained('./TxGNNExplorer')

dgl._ffi.base.DGLError: [14:31:29] /tmp/dgl_src/src/graph/heterograph.cc:120: Check failed: !rel_graphs.empty(): Empty heterograph is not allowed. The same error appears when I am trying to initialize the model.

this could be due to mistmatching version of DGL. I am on Mac M1. So I cant install 0.5.2 version of DGL. pip install "dgl==0.5.2" ERROR: Could not find a version that satisfies the requirement dgl==0.5.2 (from versions: 0.9.0, 0.9.1, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.1.2, 1.1.2.post1, 1.1.3, 2.0.0, 2.1.0) ERROR: No matching distribution found for dgl==0.5.2

It seems that 0.5.2 is also not present in https://data.dgl.ai/wheels/repo.html.

Is it possible to create a new release with latest version of DGL?

michellemli commented 5 months ago

I encountered the same error even with dgl==0.5.2. But I realized that I did not install a cuda version of PyTorch because this error was raised (I removed the try/except statement to figure out what error was being skipped):

AssertionError: Torch not compiled with CUDA enabled

Do you have a GPU on your system? If so, did you install the cuda or cpu version of PyTorch?

Another option to check whether this is actually your error is to set the device to cpu instead of cuda.

If this is not relevant to your error, maybe try removing the try/except statement to figure out what error is actually being skipped?

===== Edit =====

FYI, I still had problems with dgl==0.5.2 because it did not have cuda enabled. I managed to get the code in the README working with dgl==0.6.1 for cuda 10.2.

l4b4r4b4b4 commented 1 week ago

I encountered the same error even with dgl==0.5.2. But I realized that I did not install a cuda version of PyTorch because this error was raised (I removed the try/except statement to figure out what error was being skipped):

AssertionError: Torch not compiled with CUDA enabled

Do you have a GPU on your system? If so, did you install the cuda or cpu version of PyTorch?

Another option to check whether this is actually your error is to set the device to cpu instead of cuda.

If this is not relevant to your error, maybe try removing the try/except statement to figure out what error is actually being skipped?

===== Edit =====

FYI, I still had problems with dgl==0.5.2 because it did not have cuda enabled. I managed to get the code in the README working with dgl==0.6.1 for cuda 10.2.

CUDA 10.2?

Is it compatible to more up-to-date versions of CUDA as well? Just trying with following base image :crossed_fingers: pytorch/pytorch:2.2.0-cuda12.1-cudnn8-devel

/EDIT

I switched to cuda 10.2 pytorch 1.8.1 and was able to load TxData successfully using the full kg.csv:

Using backend: pytorch
Found local copy...
Found local copy...
Found local copy...
Found saved processed KG... Loading...
Splits detected... Loading splits....
Creating DGL graph....
Done!

However when trying to load the pre-trained model I am stuck at loading it as follows:

TxData = TxData(data_folder_path="./data")
TxData.prepare_split(split="full_graph", seed=42, no_kg=False)
TxGNN = TxGNN(
    data=TxData,
    weight_bias_track=False,
    proj_name="TxGNN",  # wandb project name
    exp_name="TxGNN",  # wandb experiment name
    device="cuda:0",  # define your cuda device
)
logger.info(str(f"Loading pre-trained GNN model ... {repr(TxGNN)}"))
TxGNN.load_pretrained(path="/model")
logger.info(str(f"Loading pre-trained GNN model successfull! {repr(TxGNN)}"))