test_multiprocessing-ipc.py 433 Bytes
Newer Older
1
2
3
import os
import unittest

4
5
import dgl

6
7
8
9
import torch as th
import torch.multiprocessing as mp


10
11
12
13
def sub_ipc(g):
    print(g)
    return g

14
15

@unittest.skipIf(os.name == "nt", reason="Do not support windows yet")
16
def test_torch_ipc():
17
    g = dgl.graph(([0, 1, 2], [1, 2, 3]))
18
    ctx = mp.get_context("spawn")
19
    p = ctx.Process(target=sub_ipc, args=(g,))
20
21
22
23
24
25

    p.start()
    p.join()


if __name__ == "__main__":
26
    test_torch_ipc()