当前位置:   article > 正文

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

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:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

file
在修改下边120行左右

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/861448
推荐阅读
相关标签
  

闽ICP备14008679号