Skip to content

Commit

Permalink
[EM] Small fixes for the example
Browse files Browse the repository at this point in the history
- Setup rmm in the initializer.
  • Loading branch information
trivialfis committed Oct 25, 2024
1 parent 18edf86 commit 212ffca
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions demo/guide-python/distributed_extmem_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
- cupy
- rmm
- python-cuda
"""

Expand Down Expand Up @@ -100,7 +99,6 @@ def reset(self) -> None:
def setup_rmm() -> None:
"""Setup RMM for GPU-based external memory training."""
import rmm
from cuda import cudart
from rmm.allocators.cupy import rmm_cupy_allocator

if not xgboost.build_info()["USE_RMM"]:
Expand Down Expand Up @@ -170,7 +168,8 @@ def initializer(device: str) -> None:
if device == "cuda":
lop, sidx = mp.current_process().name.split("-")
idx = int(sidx) # 1-based indexing from loky
os.environ["CUDA_VISIBLE_DEVICES"] = str(int(sidx) - 1)
os.environ["CUDA_VISIBLE_DEVICES"] = str(int(idx) - 1)
setup_rmm()

with get_reusable_executor(
max_workers=n_workers, initargs=(args.device,), initializer=initializer
Expand Down

0 comments on commit 212ffca

Please sign in to comment.