MCPcopy Create free account
hub / github.com/dmlc/xgboost / initializer

Function initializer

demo/guide-python/distributed_extmem_basic.py:262–274  ·  view source on GitHub ↗
(device: str)

Source from the content-addressed store, hash-verified

260 rabit_args = tracker.worker_args()
261
262 def initializer(device: str) -> None:
263 # Set CUDA device before launching child processes.
264 if device == "cuda":
265 # name: LokyProcess-1
266 _, sidx = mp.current_process().name.split("-")
267 idx = int(sidx) - 1 # 1-based indexing from loky
268 # Assuming two workers for demo.
269 devices = ",".join([str(idx), str((idx + 1) % n_workers)])
270 # P0: CUDA_VISIBLE_DEVICES=0,1
271 # P1: CUDA_VISIBLE_DEVICES=1,0
272 os.environ["CUDA_VISIBLE_DEVICES"] = devices
273 setup_numa()
274 setup_async_pool()
275
276 with get_reusable_executor(
277 max_workers=n_workers,

Callers

nothing calls this directly

Calls 2

setup_numaFunction · 0.85
setup_async_poolFunction · 0.70

Tested by

no test coverage detected