benedekrozemberczki / pytorch_geometric_temporal

PyTorch Geometric Temporal: Spatiotemporal Signal Processing with Neural Machine Learning Models (CIKM 2021)
MIT License
2.63k stars 370 forks source link

Working Colab Notebooks #251

Closed bsbodden closed 1 year ago

bsbodden commented 1 year ago

Are there some recent Jupyter notebooks that successfully install their dependencies and properly run on Google Colab? None of the notebooks in the repo seem to work on Colab as of Oct 2023, and I've given up with a local install due to the M2 chip set being Python problematic. Any links or repos with working code would be appreciated it.

bsbodden commented 1 year ago

I tried my luck without attempting to install some of the torch dependencies wheels. The code below worked on Colab:

!python -c "import torch; print(torch.__version__)"
!python -c "import torch; print(torch.version.cuda)"
!pip install torch-geometric-temporal

It did report some errors:

...
Installing collected packages: torch_scatter, torch_sparse, pandas, torch_geometric, torch-geometric-temporal
  Attempting uninstall: pandas
    Found existing installation: pandas 1.5.3
    Uninstalling pandas-1.5.3:
      Successfully uninstalled pandas-1.5.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
google-colab 1.0.0 requires pandas==1.5.3, but you have pandas 1.3.5 which is incompatible.
plotnine 0.12.3 requires pandas>=1.5.0, but you have pandas 1.3.5 which is incompatible.
xarray 2023.7.0 requires pandas>=1.4, but you have pandas 1.3.5 which is incompatible.
Successfully installed pandas-1.3.5 torch-geometric-temporal-0.54.0 torch_geometric-2.3.1 torch_scatter-2.1.1 torch_sparse-0.6.17

But the following code seems to run to completion:

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import networkx as nx

import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv
from torch_geometric_temporal.nn.recurrent import A3TGCN2
from torch_geometric_temporal.signal import temporal_signal_split

# GPU support
DEVICE = torch.device('cuda') # cuda
shuffle=True
batch_size = 32

with output:

100%|██████████| 50/50 [00:20<00:00,  2.50it/s]
MSE: 1.0027
bsbodden commented 1 year ago

But as mentioned, all the notebooks included in the repo are not runnable as they are.

bsbodden commented 1 year ago

Will try to send a PR for those

davidshumway commented 8 months ago

I got it working with the following:

!pip install --no-index torch-scatter -f https://pytorch-geometric.com/whl/torch-2.1.0+cpu.html > /dev/null
!pip install --no-index torch-sparse -f https://pytorch-geometric.com/whl/torch-2.1.0+cpu.html > /dev/null
!pip install --no-index torch-cluster -f https://pytorch-geometric.com/whl/torch-2.1.0+cpu.html > /dev/null
!pip install --no-index torch-spline-conv -f https://pytorch-geometric.com/whl/torch-2.1.0+cpu.html > /dev/null
!pip install torch-geometric > /dev/null
!pip install geomloss[full] > /dev/null
!pip install torch-geometric-temporal

With a few minimal errors:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
lida 0.0.10 requires fastapi, which is not installed.
lida 0.0.10 requires kaleido, which is not installed.
lida 0.0.10 requires python-multipart, which is not installed.
lida 0.0.10 requires uvicorn, which is not installed.
bigframes 0.20.0 requires pandas<2.1.4,>=1.5.0, but you have pandas 1.3.5 which is incompatible.
google-colab 1.0.0 requires pandas==1.5.3, but you have pandas 1.3.5 which is incompatible.
plotnine 0.12.4 requires pandas>=1.5.0, but you have pandas 1.3.5 which is incompatible.
xarray 2023.7.0 requires pandas>=1.4, but you have pandas 1.3.5 which is incompatible.
Successfully installed pandas-1.3.5 torch-geometric-temporal-0.54.0