(device: str)
| 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, |
nothing calls this directly
no test coverage detected