snap-stanford / ogb

Benchmark datasets, data loaders, and evaluators for graph machine learning
https://ogb.stanford.edu
MIT License
1.89k stars 397 forks source link

ImportError: cannot import name 'PygPCQM4MDataset' #216

Closed ZicongLin-GDUT closed 3 years ago

ZicongLin-GDUT commented 3 years ago

Hi! I ran into some problems using the torch_geometric version of the baseline code. When I submit the Python command once at the Terminal, it shows that it cannot be imported.

Report is followed:

(gnn) etower@etower:~/lzc/pcqm4m$ python main_gnn.py Traceback (most recent call last): File "main_gnn.py", line 18, in from ogb.lsc import PygPCQM4MDataset, PCQM4MEvaluator ImportError: cannot import name 'PygPCQM4MDataset'

However, when I use Python Console, it works well.

(gnn) etower@etower:~/lzc/pcqm4m$ python Python 3.6.13 |Anaconda, Inc.| (default, Feb 23 2021, 21:15:04) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from ogb.lsc import PygPCQM4MDataset >>> dataset = PygPCQM4MDataset(root='dataset')

I have tried to reinstall numpy, pandas, and torch_geometric but it didn't work. And I've installed torch, CUDA, and rdkit.

ZicongLin-GDUT commented 3 years ago

Well, perhaps this problem can be solved by using a conda installation instead of a pip installation. But when I use conda-version, I have another problem: I can't use graph_pooling=attention/set2set. The error is followed:

Traceback (most recent call last): File "main_gnn.py", line 231, in main() File "main_gnn.py", line 191, in main train_mae = train(model, device, train_loader, optimizer) File "main_gnn.py", line 30, in train pred = model(batch).view(-1, ) File "/home/etower/anaconda3/envs/gnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "/home/etower/lzc/pcqm4m/gnn.py", line 65, in forward h_graph = self.pool(h_node, batched_data.batch) File "/home/etower/anaconda3/envs/gnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, **kwargs) File "/home/etower/anaconda3/envs/gnn/lib/python3.6/site-packages/torch_geometric/nn/glob/attention.py", line 52, in forward gate = softmax(gate, batch, num_nodes=size) RuntimeError: nvrtc: error: invalid value for --gpu-architecture (-arch)

nvrtc compilation failed:

define NAN __int_as_float(0x7fffffff)

define POS_INFINITY __int_as_float(0x7f800000)

define NEG_INFINITY __int_as_float(0xff800000)

template device T maximum(T a, T b) { return isnan(a) ? a : (a > b ? a : b); }

template device T minimum(T a, T b) { return isnan(a) ? a : (a < b ? a : b); }

extern "C" global void func_1(float t0, float t1, float aten_exp_flat) { { if (512 blockIdx.x + threadIdx.x<3644 ? 1 : 0) { float v = __ldg(t0 + 512 blockIdx.x + threadIdx.x); float v_1 = __ldg(t1 + 512 blockIdx.x + threadIdx.x); aten_exp_flat[512 * blockIdx.x + threadIdx.x] = expf(v - v_1); } } }

Segmentation fault (core dumped)

This problem has been bothering me for a long time. I hope I can get your help.Thanks!

weihua916 commented 3 years ago

Hi, I did not have any issue with --graph_pooling attention nor --graph_pooling set2set. Can you try updating/properly instaling all of your pytorch geometric related packages? Seems like your package installation has some bug (compilation error).

ZicongLin-GDUT commented 3 years ago

Hi, I did not have any issue with --graph_pooling attention nor --graph_pooling set2set. Can you try updating/properly instaling all of your pytorch geometric related packages? Seems like your package installation has some bug (compilation error).

Hi, Thanks for your reply! I have reinstalled pytorch and torch_geometric several times, includes all the related packages. Maybe it's my CUDA's wrong, I want to try other pytorch and CUDA versions. Could you tell me about your environment?

The current environment is as follows: python=3.6.13 pytorch=1.7.0 cudatoolkit=11.0 torch_geometric=1.7.0

weihua916 commented 3 years ago

Of course. Here is my environment. python 3.7.4 pytorch 1.8.1 torch_geometric 1.7.0 Cuda 10.2

weihua916 commented 3 years ago

torch_scatter version/installation may also matter. Mine is 2.0.6 Please check if all the other torch_geometric associated libraries are properly installed.

ZicongLin-GDUT commented 3 years ago

Thank you! I have solved the problem now. After I change the environment to the following version, the program can run normally. So I think the problem may be with cuda11.0 on my server.

New environment: python 3.6.13 pytorch 1.8.0 cuda11.1 torch_geometric 1.7.0(with torch-cluster 1.5.9; torch-scatter 2.0.6; torch-sparse 0.6.9; torch-spline-conv 1.2.1)