deepinsight / insightface

State-of-the-art 2D and 3D Face Analysis Project
https://insightface.ai
21.92k stars 5.26k forks source link

using cuda synthetic face data in MXFaceDataset #2578

Open ericyq opened 1 month ago

ericyq commented 1 month ago

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)