【复现失败】复现tensor2tensor代码时遇到的问题和相关链接

tensor2tensor源代码:tensorflow/tensor2tensor

版本依赖问题:

≥Python 3.6(实测Python=3.9安装tensor2tensor失败)

tensor2tensor只支持2.0以下的版本tensorflow

Tensor2Tensor 安装与配置完全指南-CSDN博客

关于tensor2tensor与tensorflow版本冲突的解决方案 - 单亚林 - 博客园

tensor2tensor安装bug修复 - 华东博客 - 博客园

 

遇到以下报错信息时,

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/tensor2tensor/

关闭代理软件可以解决。

 

报错信息:

CondaValueError: Malformed version string '~': invalid character(s).

大概是conda下载源的问题

 

Tensorflow与Python、CUDA、cuDNN的版本对应表_tensorflow版本对应-CSDN博客

开头的链接里有人说用tensorflow-gpu1.15.2跑通了,tensorflow-gpu1.15.2对应CUDA 10,而CUDA10最高只有Ubuntu18.04的安装包,所以改用Ubuntu18.04。

cudatoolkit、cudnn需要单独下载安装包安装。

Ubuntu18.04下安装CUDA 10.0和cuDNN 7.4 - infocodez - 博客园

实际环境和包:

Ubuntu18.04

tensor2tensor1.15.7

tensorflow-gpu1.15.2

tensorflow-datasets3.2.1

numpy1.18.0

cuDNN 7.4

CUDA 10(CUDA Toolkit)

 

python3.7的环境下pip install tensor2tensor后运行t2t-trainer --registry_help报错AttributeError: 'NoneType' object has no attribute 'copy'

修改tensor2tensor/rl/gym_utils.py代码解决,参考Change kwargs=None optional parameter to **kwargs by TimOgden · Pull Request #1908 · tensorflow/tensor2tensor

 

报错:AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'IndexedSlices'

因为2019年6月4日,class IndexedSlices从ops.py移除

Move IndexedSlices to its own python module · tensorflow/tensorflow@88ed977

最后一个支持该属性的版本:v1.14.0-rc0

 

新建python3.7的虚拟环境

conda create -n t2t python=3.7

tensor2tensor安装bug修复 - 华东博客 - 博客园

pip install dopamine-rl==1.0.5

pip install tensor2tensor

之后再安装tensorflow:

pip install tensorflow-gpu==1.15.2

安装CUDA 10和cuDNN 7.4

指定其他tf库为1.15的对应版本。

报错:

ImportError: This version of TensorFlow Datasets requires TensorFlow version >= 2.1.0; Detected an installation of version 1.15.2. Please upgrade TensorFlow to proceed.

支持tensorflow1.15的TensorFlow Datasets的最新版是 3.2.1

tensorflow_datasets 版本兼容 tensorflow 1.15 - 编程之家

Remove support for TF 1.15 · tensorflow/datasets@a2fe67c

pip install tensorflow-datasets==3.2.1

报错:

NotImplementedError: Cannot convert a symbolic Tensor (transformer/parallel_0_5/transformer/transformer/body/strided_slice_7:0) to a numpy array.

可能因为numpy版本不适配

pip install numpy==1.18.0

 

复制之前环境生成的数据,然后训练,但报错:tensorflow.python.framework.errors_impl.DataLossError: corrupted record at 0

重新生成数据解决。

 

报错:tensorflow/stream_executor/cuda/cuda_blas.cc:428] failed to run cuBLAS routine: CUBLAS_STATUS_EXECUTION_FAILED

AI回答:RTX 40 系列显卡最低需要 CUDA 11.8 / cuDNN 8.6 才能正常运行。用 CUDA 10.0 会导致 cuBLAS 内核不支持 Ampere/ADA 架构,进而 GEMM 失败。

4060显卡,最低需要CUDA11.8。至此,复现失败,缺乏匹配的硬件环境(显卡)。

CUDA安装&cuDNN、TensorRT版本匹配_python_initative-GitCode 开源社区

RTX4060对应的cuda版本_4060 cuda-CSDN博客

40系显卡深度学习配置指南(pytorch) - 哔哩哔哩

Minimum required CUDA version by GPU - CUDA / CUDA Setup and Installation - NVIDIA Developer Forums

 

其他参考链接

tf1.15 使用过程中的一些坑_but you have botocore 1.21.2 which is incompatible-CSDN博客

“变形金刚”Google Tensor2Tensor系统 - 知乎

三万字最全解析!从零实现Transformer(小白必会版😃) - 知乎

Breeze648/Transformer-from-Scratch: 本仓库定位为 AI论文复现 / 从零实现 Transformer。

Transformer 零基础解析教程,完整版代码最终挑战(4/4) - 知乎

Attention Is All You Need论文精读(逐段解析)_attion is all your need-CSDN博客

李沐精读论文:transformer 《Attention Is All You Need》 by Google_attention is all you need stablediffution-CSDN博客

Transformer 论文精读与完整代码复现【Attention Is All You Need】_attention is all you need精读-CSDN博客

废弃

新建虚拟环境Python=3.9,conda create -n t2t python=3.9 。

pip install tensor2tensor==1.15.7 时,使用pip清华源时安装异常缓慢,出现pip is looking at multiple versions of optax to determine which version is compatible with other requirements. This could take a while.问题,换成pip阿里源后还是出现同样问题并且很缓慢,不知道是不是因为虚拟环境中设置的python版本是3.9,之前设置为python3.7的时候pip install tensor2tensor没有出现安装异常缓慢的问题。

改为Python=3.8的虚拟环境,conda create -n t2t8 python=3.8, 安装pip install tensor2tensor[tensorflow_gpu]正常

但运行t2t-trainer --registry_help报错AttributeError: module 'numpy' has no attribute 'bool'. 

降级numpy版本pip install numpy==1.23.2 解决

“AttributeError: module ‘numpy‘ has no attribute ‘bool‘”解决方法 - 海_纳百川 - 博客园

 

wsl安装的Ubuntu24.04,Ubuntu24.04上安装CUDA 11.2,需要对gcc降档。好像是对gcc降档失败,又安装了Ubuntu20.04。

Ubuntu 20.04安装CUDA & CUDNN 手把手带你撸_ubuntu20.04安装cuda-CSDN博客

Ubuntu20.04下CUDA、cuDNN的详细安装与配置过程(图文)_ubuntu cudnn安装-CSDN博客

linux下使用 tar 来压缩和解压 tar.gz 和 tar.xz 文件_解压tar.gz-CSDN博客

ubuntu20.04安装/重装 cuda11.4、cudnn - 小小灰迪 - 博客园

解压.tar.xz文件,使用tar Jxvf archive_name.tar.xz命令

Ubuntu20.04无法安装CUDA 10,换成Ubuntu18.04。

 

posted @ 2025-09-10 15:56  infocodez  阅读(19)  评论(0)    收藏  举报