当前位置:   article > 正文

深度学习Apex库出现报错‘IndexError: tuple index out of range‘的解决方法

indexerror: tuple index out of range

深度学习Apex库出现报错'IndexError: tuple index out of range'的解决方法


转自: https://github.com/NVIDIA/apex/issues/694#issuecomment-918833904

bug产生原因:使用了高版本的python或者apex库【到底是哪一个还不确定】,导致GPU上运行的pytorch深度学习代码出现’IndexError: tuple index out of range’报错。

解决方法:
从github上https://github.com/NVIDIA/apex下载的apex库在正式安装之前,首先修改源代码。
修改源代码中的apex-master/apex/amp/utils.py文件

if cached_x.grad_fn.next_functions[1][0].variable is not x:
  • 1

修改为

if cached_x.grad_fn.next_functions[0][0].variable is not x:
  • 1

之后再进入apex-master文件夹执行

pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --global-option="--cpp_ext" --global-option="--cuda_ext" ./
  • 1

编译安装。
实测这个解决方案成功修复了报错的问题。

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

闽ICP备14008679号