Giter Site home page Giter Site logo

Comments (13)

rusty1s avatar rusty1s commented on June 15, 2024 2

This makes sense, and we should add an assertion to prevent this. The NeighborSampler is a CPU-op, and hence expects data being on the CPU.

from pytorch_cluster.

rusty1s avatar rusty1s commented on June 15, 2024

Can you test if the test suite of torch-cluster works for you?

from pytorch_cluster.

xiaojinglu avatar xiaojinglu commented on June 15, 2024

Can you test if the test suite of torch-cluster works for you?

I just run python setup.py install and then python setup.py test, all tests passed.

test/test_fps.py ....
test/test_graclus.py ............................
test/test_grid.py ........................................................
test/test_knn.py ........
test/test_nearest.py ....
test/test_radius.py ........
test/test_rw.py ..
test/test_sampler.py .

----------- coverage: platform linux, python 3.6.8-final-0 -----------
Name                        Stmts   Miss  Cover
-----------------------------------------------
torch_cluster/__init__.py      10      0   100%
torch_cluster/fps.py           10      0   100%
torch_cluster/graclus.py       10      0   100%
torch_cluster/grid.py           9      0   100%
torch_cluster/knn.py           37      0   100%
torch_cluster/nearest.py       21      0   100%
torch_cluster/radius.py        31      0   100%
torch_cluster/rw.py            11      0   100%
torch_cluster/sampler.py        8      0   100%
-----------------------------------------------
TOTAL                         147      0   100%


============================= 111 passed in 24.19s =============================

from pytorch_cluster.

rusty1s avatar rusty1s commented on June 15, 2024

Okay, I did not expect this. So installation succeed. The reddit.py example works for me, so I am not sure what may causes this issue. Is it possible to do some debugging on your side?

from pytorch_cluster.

Chandrahasd avatar Chandrahasd commented on June 15, 2024

I am also facing the same issue.
My graph has 643474 nodes and 1222204 edges.
I am trying to use NeighborSampler to generate batches of size 128. I tried using full neighborhood (size=1.0) as well as subsampling (e.g. size=16).
In both cases, the code terminates with Segmentation Fault at this line of pytorch_cluster/torch_cluster/sampler.py file.

The example code reddit.py from Pytorch Geometric works fine for me.

from pytorch_cluster.

rusty1s avatar rusty1s commented on June 15, 2024

Can you send me your data.edge_index per mail? Curious to debug this!

from pytorch_cluster.

xiaojinglu avatar xiaojinglu commented on June 15, 2024

My code terminates with Segmentation Fault at this line too when I run python reddit.py

from pytorch_cluster.

Chandrahasd avatar Chandrahasd commented on June 15, 2024

Can you send me your data.edge_index per mail? Curious to debug this!

@rusty1s, I shared the data.edge_index file over email.
Thank you for looking into this issue.

from pytorch_cluster.

rusty1s avatar rusty1s commented on June 15, 2024

I received your file and will look into it. An initial guess is that it may be due to isolated nodes.

from pytorch_cluster.

Chandrahasd avatar Chandrahasd commented on June 15, 2024

I thought that too.
I did try adding the self-loops to avoid zero-degree nodes, but it wasn't enough to avoid the error.

from pytorch_cluster.

rusty1s avatar rusty1s commented on June 15, 2024

Works flawless for me:

import torch
from torch_geometric.read import read_txt_array
from torch_geometric.data import Data
from torch_geometric.data import NeighborSampler

edge_index = read_txt_array('edge_indices.txt', sep=' ', dtype=torch.long)
edge_index = edge_index.t().contiguous()
data = Data(edge_index=edge_index)
print(data)

loader = NeighborSampler(data, size=1.0, num_hops=2, batch_size=100,
                         shuffle=False, add_self_loops=False)

for data_flow in loader():
    print(data_flow)

Can you run the code and see if it works for you?

from pytorch_cluster.

Chandrahasd avatar Chandrahasd commented on June 15, 2024

This code works.
The problem happens when either edge_index or data object or both are in GPU memory.

import torch
from torch_geometric.read import read_txt_array
from torch_geometric.data import Data
from torch_geometric.data import NeighborSampler

# Put edge_index in GPU memory
edge_index = read_txt_array('edge_indices.txt', sep=' ', dtype=torch.long).cuda()
edge_index = edge_index.t().contiguous()
# Put data object to GPU memory
data = Data(edge_index=edge_index).to('cuda')
print(data)

loader = NeighborSampler(data, size=1.0, num_hops=2, batch_size=100,
                         shuffle=False, add_self_loops=False)

for data_flow in loader():
    print(data_flow)

Output:

torch_geometric/data/data.py:177: UserWarning: The number of nodes in your data object can only be inferred by its edge indices, and hence may result in unexpected batch-wise behavior, e.g., in case there exists isolated nodes. Please consider explicitly setting the number of nodes for this data object by assigning it to data.num_nodes.
  warnings.warn(__num_nodes_warn_msg__.format('edge'))
Segmentation fault (core dumped)

from pytorch_cluster.

github-actions avatar github-actions commented on June 15, 2024

This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?

from pytorch_cluster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.