模型训练—-apex库报错IndexError: tuple index out of range

问题描述

在训练模型的过程中遇到了apex库的报错IndexError: tuple index out of range导致无法训练。在github查询后找到了解决方法

file

问题解决

需要修改/apex-master/apex/amp/utils.py这个文件的代码
从93行开始修改

if x in cache:
        cached_x = cache[x]
        next_functions_available = False
        if x.requires_grad and cached_x.requires_grad:
            if len(cached_x.grad_fn.next_functions) > 1:
                next_functions_available = True
            # Make sure x is actually cached_x's autograd parent.
            if next_functions_available and cached_x.grad_fn.next_functions[1][0].variable is not x:

file

在修改下边120行左右

 elif x.requires_grad and cached_x.requires_grad and not next_functions_available:
            del cache[x]

file

最后重新运行一遍apex的安装程序,再次运行训练就不会报错了
file

如果觉得本文对您有所帮助,可以支持下博主,—分也是缘。

评论

  1. wshi666
    1 年前
    2024-4-22 22:56:10

    求大佬交一下Linux系统配置深度学习环境

    • 博主
      wshi666
      1 年前
      2024-4-23 14:28:46

      csdn上一大堆,比windows更简单,你搜下就行

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇

超多性价比流量卡,扫码查看

这将关闭于 20