Skip to content

Commit

Permalink
Update utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jalencato authored Jan 21, 2025
1 parent b10f202 commit 6959b05
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/graphstorm/gconstruct/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ def worker_fn(worker_id, task_queue, res_queue, user_parser, ext_mem_workspace):
"""
# We need to set a GPU device for each worker process in case that
# some transformations (e.g., computing BERT embeddings) require GPU computation.
multiprocessing.set_start_method("spawn", force=True)
if th.cuda.is_available():
num_gpus = th.cuda.device_count()
gpu = worker_id % num_gpus
Expand Down Expand Up @@ -296,6 +295,8 @@ def multiprocessing_data_read(in_files, num_processes, user_parser, ext_mem_work
a dict : key is the file index, the value is processed data.
"""
if num_processes > 1 and len(in_files) > 1:
if th.cuda.is_available():
multiprocessing.set_start_method("spawn", force=True)
processes = []
manager = multiprocessing.Manager()
task_queue = manager.Queue()
Expand Down

0 comments on commit 6959b05

Please sign in to comment.