pytorch出现 RuntimeError: transform: failed to synchronize: cudaErrorIllegalAddress: an illegal memory access was encountered
导致原因可能有两种:
- 忘记了model.to(device)
- pytorch版本不兼容,在使用transformers包的的时候可能有类似的情况出现
大多数都是第一种,所以在模型定义完之后记得移到GPU:
model = MyModel()
device = torch.device('cuda')
model.to(device)
所有评论(0)