graphcore / ogb-lsc-pcqm4mv2

The OGB-LSC is the Large Scale Competition by Open Graph Benchmark to help accelerate research into machine learning on graph structured data
MIT License
68 stars 14 forks source link

name '_c' is not defined #10

Closed vindakunte closed 1 year ago

vindakunte commented 1 year ago

I ran into the above name error while trying to run the Paperspace notebook for inference. The error occurs while importing the notebook-utils file. I've tried restarting the kernel but that does not seem to work. The following error message appears: NameError Traceback (most recent call last) Cell In[4], line 3 1 get_ipython().run_line_magic('matplotlib', 'inline') 2 # Need notebook utils as first import as it modifies the path ----> 3 import notebook_utils 5 import os 6 import yaml

File /notebooks/ogb-competition/notebook_utils.py:7 4 sys.path.insert(0, str(_ogb_competition_directory)) 6 # Make it look like this file is the original notebook_utils ----> 7 from ogb_utils import *

File /notebooks/ogb-competition/pcqm4mv2_submission/ogb_utils.py:21 19 from custom_callbacks import CheckpointCallback 20 from data_utils.input_spec import create_inputs_from_features ---> 21 from model.utils import create_model, get_loss_functions, get_metrics, get_tf_dataset 22 from pipeline.pipeline_stage_assignment import pipeline_model 23 from pipeline.pipeline_stage_names import PIPELINE_ALLOCATE_PREVIOUS, PIPELINE_NAMES

File /notebooks/ogb-competition/pcqm4mv2_submission/model/utils.py:9 6 import tensorflow as tf 7 import wandb ----> 9 from data_utils.packed_batch_generator import PackedBatchGenerator 10 from model.gnn.loss import get_loss_functions_gnn, MaskedMeanAbsoluteError 11 from model.gnn.losses_and_metrics import MaskedMeanAbsoluteError

File /notebooks/ogb-competition/pcqm4mv2_submission/data_utils/packed_batch_generator.py:10 7 import numpy as np 8 import tensorflow as tf ---> 10 from data_utils.load_dataset import OGBGraphData 11 from data_utils.packing import pack_dataset 12 from data_utils.utils import apply_categorical_feature_noise, normalize_ogbBL, normalize_atom_distances, weighted_sample

File /notebooks/ogb-competition/pcqm4mv2_submission/data_utils/load_dataset.py:11 9 import rdkit 10 import tensorflow as tf ---> 11 from ogb.graphproppred import GraphPropPredDataset 12 from ogb.lsc import PCQM4Mv2Dataset 13 from ogb.utils import smiles2graph

File /opt/tensorflow_2/lib/python3.8/site-packages/ogb/graphproppred/init.py:2 1 from .evaluate import Evaluator ----> 2 from .dataset import GraphPropPredDataset 4 try: 5 from .dataset_pyg import PygGraphPropPredDataset

File /opt/tensorflow_2/lib/python3.8/site-packages/ogb/graphproppred/dataset.py:6 4 import os.path as osp 5 from ogb.utils.url import decide_download, download_url, extract_zip ----> 6 from ogb.io.read_graph_raw import read_csv_graph_raw, read_binary_graph_raw 7 import torch 9 class GraphPropPredDataset(object):

File /opt/tensorflow_2/lib/python3.8/site-packages/ogb/io/init.py:1 ----> 1 from .save_dataset import DatasetSaver

File /opt/tensorflow_2/lib/python3.8/site-packages/ogb/io/save_dataset.py:1 ----> 1 import torch 2 import pandas as pd 3 import os

File /opt/tensorflow_2/lib/python3.8/site-packages/torch/init.py:465 451 raise ImportError(textwrap.dedent(''' 452 Failed to load PyTorch C extensions: 453 It appears that PyTorch has loaded the torch/_C folder (...) 461 or by running Python from a different directory. 462 ''').strip()) from None 463 raise # If file is not None the cause is unknown, so just re-raise. --> 465 for name in dir(C): 466 if name[0] != '' and not name.endswith('Base'): 467 all.append(name)

NameError: name '_C' is not defined

adamjsanders277 commented 1 year ago

Hi @vindakunte,

I also see your issue but was able to fix it by adding the following lines to the requirements.txt and restarting the kernel:

--find-links https://download.pytorch.org/whl/cpu/torch_stable.html
torch==2.0.1+cpu
vindakunte commented 1 year ago

Thank you for patching the code in the requirements.txt file the inference notebook runs smoothly now. I just wanted to know what was the cause of this error as I could not figure it out. Please go ahead and close the issue as you respond