Skip to content

Commit b407fb7

Browse files
committed
add explicit set_device
1 parent 1cf7ee6 commit b407fb7

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎src/spidr/train.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def train(cfg: Config) -> None:
7878

7979
logger.info("Building model, optimizer, and dataloaders")
8080
device = torch.device(f"cuda:{os.environ['LOCAL_RANK']}")
81+
torch.cuda.set_device(device)
8182
dtype = {"float32": torch.float32, "float16": torch.float16, "bfloat16": torch.bfloat16}[cfg.optimizer.dtype]
8283
model = build_model(cfg=cfg.model, model_type=cfg.run.model_type, checkpoint=cfg.run.init_ckpt)
8384
model = model.to(device).train()

0 commit comments

Comments
 (0)