E:\PulmonaryNodulesDetection_v8\ultralytics\utils\checks.py:651: FutureWarning: torch.cuda.amp.autocast(args…) is deprecated. Please use torch.amp.autocast(‘cuda’, args…) instead.
with torch.cuda.amp.autocast(True):

这个警告提示您在代码中使用了已被弃用的 torch.cuda.amp.autocast(True),而 PyTorch 建议您使用新的 API 形式 torch.amp.autocast(‘cuda’, enabled=True)。

解决方法:
您需要将代码中的 torch.cuda.amp.autocast(True) 替换为 torch.amp.autocast(‘cuda’, enabled=True)。

在文件 E:\PulmonaryNodulesDetection_v8\ultralytics\utils\checks.py 中的第 651 行,将以下代码:

with torch.cuda.amp.autocast(True):

修改为:
with torch.amp.autocast(‘cuda’, enabled=True):

修改后的代码示例:
# 原代码:
with torch.cuda.amp.autocast(True):
# 训练代码逻辑

# 修改后:
with torch.amp.autocast(‘cuda’, enabled=True):
# 训练代码逻辑

这样做将使代码与最新的 PyTorch 版本兼容,并且不会再出现这个警告。

总结:
将 torch.cuda.amp.autocast(True) 替换为 torch.amp.autocast(‘cuda’, enabled=True)。
通过这种修改,您可以确保代码的未来兼容性并消除该警告。

声明:本站所有项目资源都可以正常运行,亲测无错!而且我们录制了演示视频,在我们注明的环境版本下,项目运行效果完全和演示视频一致。客服QQ:下载须知