2 Matching Annotations
  1. Last 7 days
    1. python sample.py --out_dir=out-shakespeare-char

      针对mac环境的话,要改一下:

      修改前:

      python device_type = 'cuda' if 'cuda' in device else 'cpu'

      修改后:

      python device_type = 'cuda' if 'cuda' in device else ('cpu' if device == 'cpu' else 'cpu')

      原因: 这个变量用于决定后续是否启用 torch.amp.autocast(混合精度)。原逻辑只有 'cuda' 和 'cpu' 两种情况。当 device='mps' 时,'cuda' in device 为 False,所以会走 else 分支 ,结果也是 'cpu',从而使用 nullcontext()(不启用 autocast)。这样避免了 MPS 上 <br /> autocast 的兼容性问题。