AssertionError:
Found no NVIDIA driver on your system. Please check that you
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
没有gpu时,错误写法:
print("aaaa",True if torch.cuda.is_available else False)
结果为True
正确写法:
cuda =torch.cuda.is_available()
本文介绍了在使用PyTorch时如何正确检查系统是否具备CUDA支持,以确认GPU能否用于加速计算。错误的写法可能会误导用户,即使没有GPU也会返回True。正确的判断方式是确保在没有GPU的情况下返回False。
4905

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



