欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > 修复笔记:SkyReels-V2 项目中的 torch.cuda.amp.autocast 警告和错误

修复笔记:SkyReels-V2 项目中的 torch.cuda.amp.autocast 警告和错误

2025/5/5 16:24:49 来源:https://blog.csdn.net/u014451778/article/details/147705198  浏览:    关键词:修复笔记:SkyReels-V2 项目中的 torch.cuda.amp.autocast 警告和错误

#工作记录

一、问题描述

在运行项目时,出现以下警告和错误:

FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.with torch.cuda.amp.autocast(dtype=pipe.transformer.dtype), torch.no_grad():
...
TypeError: set_autocast_enabled(): argument 'enabled' (position 2) must be bool, not str

二、受影响的文件和行号

  1. 文件:F:\PythonProjects\SkyReels-V2\skyreels_v2_infer\pipelines\text2video_pipeline.py

    • 行号:第 86 行和第 93 行

    • 原代码

      with torch.cuda.amp.autocast(dtype=self.transformer.dtype), torch.no_grad():

三、修复过程

1. 查找相关代码

在项目中查找使用 torch.cuda.amp.autocast 的代码片段。

2. 修改代码

根据警告提示,将 torch.cuda.amp.autocast 替换为 torch.amp.autocast,并正确设置参数。

3. 测试修改后的代码

重新运行 generate_video.py 脚本,确认警告是否消失。

四、修改后的代码

  1. text2video_pipeline.py 文件第 86 行

    with torch.amp.autocast(device_type='cuda', dtype=self.transformer.dtype), torch.no_grad():

五、验证修改

完成上述修改后,重新运行项目以确保所有问题都已解决:

python generate_video.py --resolution 540P

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词