在执行 torch.eye(weights.size(1), dtype=torch.bool, device=weights.device) 这句话的时候,出现了报错信息。
RuntimeError: eye_out not supported on CUDAType for Bool
参考这篇文章,链接
将 dtype=torch.bool 改为 dtype=torch.uint8,即torch.eye(weights.size(1), dtype=torch.uint8, device=weights.device)
问题解决。

本文解决了在使用PyTorch的eye函数时遇到的错误:eye_out not supported on CUDA Type for Bool。通过将布尔类型更改为无符号整数8位(uint8),成功解决了CUDA设备上的类型不兼容问题。
1843

被折叠的 条评论
为什么被折叠?



