insightface icon indicating copy to clipboard operation
insightface copied to clipboard

using cuda synthetic face data in MXFaceDataset

Open ericyq opened this issue 9 months ago • 0 comments

latents = net(inputs.to("cuda").float(), randomize_noise=False, return_latents=True) RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method

1st method torch.multiprocessing.set_start_method("spawn", force=True) or 2nd method from multiprocessing import Pool

def test(arg1, arg2): return "hello," + arg1, arg2 + ' test', [2222, 5, 356]

if name == 'main': p = Pool(2) results = [] rslt1 = p.apply_async(test, ('world1', 'tea',))
results.append(rslt1) rslt2 = p.apply_async(test, ('world2', 'cat',))
results.append(rslt2) for r in results: a, b, c = r.get()
print(a, b, c) hello,world1 tea test [2222, 5, 356] hello,world1 cat test [2222, 5, 356]

Stop for a long time to report errors: RuntimeError: Timed out initializing process group in store based barrier on rank: 1, for key: store_based_barrier_key:1 (world_size=2, worker_count=4, timeout=0:30:00)

ericyq avatar May 11 '24 09:05 ericyq