Skip to content

The best ChatGPT that $100 can buy.

Python

Merge branch 'master' into logo/kerning-update

svlandegb996131570cd
diff --cc nanochat/common.py
index d80d4ba,a5a6d2e..13d957a
--- a/nanochat/common.py
+++ b/nanochat/common.py
@@@ -97,20 -151,20 +151,20 @@@ def compute_init(device_type="cuda"):
# Reproducibility
torch.manual_seed(42)
- torch.cuda.manual_seed(42)
+ if device_type == "cuda":
+ torch.cuda.manual_seed(42)
# skipping full reproducibility for now, possibly investigate slowdown later
# torch.use_deterministic_algorithms(True)
- # torch.backends.cudnn.deterministic = True
- # torch.backends.cudnn.benchmark = False
# Precision
- torch.set_float32_matmul_precision("high") # uses tf32 instead of fp32 for matmuls
+ if device_type == "cuda":
+ torch.set_float32_matmul_precision("high") # uses tf32 instead of fp32 for matmuls
- # Distributed setup: Distributed Data Parallel (DDP), optional
+ # Distributed setup: Distributed Data Parallel (DDP), optional, and requires CUDA
ddp, ddp_rank, ddp_local_rank, ddp_world_size = get_dist_info()
- if ddp:
+ if ddp and device_type == "cuda":
device = torch.device("cuda", ddp_local_rank)
- torch.cuda.set_device(device) # make "cuda" default to this device
+ torch.cuda.set_device(device) # make "cuda" default to this device
dist.init_process_group(backend="nccl", device_id=device)
dist.barrier()
else: