简体   繁体   English

无法运行 Tensorflow 的官方 Tensor2Tensor colab notebook

[英]Unable to run Tensorflow's official Tensor2Tensor colab notebook

I have zero experience in Tensorflow and recently started studying about NLP.我对 Tensorflow 的经验为零,最近开始研究 NLP。 Came across the Tensorflow implementation of the Transformer based on Attention is All You Need paper.偶然发现了基于Attention is All You Need论文的 Transformer 的 Tensorflow 实现。

Tensor2Tensor package has a Quick Start section which has a colab link Tensor2Tensor package 有一个快速入门部分,其中有一个 colab 链接

Quick Start快速开始
This iPython notebook explains T2T and runs in your browser using a free VM from Google, no installation needed. 这个 iPython 笔记本解释了 T2T,并使用来自 Google 的免费 VM 在您的浏览器中运行,无需安装。

I wanted to run this and it gives the error我想运行它,它给出了错误

ValueError: Tensorflow 1 is unsupported in Colab.

Your notebook should be updated to use Tensorflow 2.
See the guide at https://www.tensorflow.org/guide/migrate#migrate-from-tensorflow-1x-to-tensorflow-2.

Have no clue on what to change.不知道要改变什么。

I'm I not supposed to run the colab but just observe the already printed results.我不应该运行 colab,而只是观察已经打印的结果。 Is there a Tensorflow 2 version which I can run and see.是否有我可以运行并查看的 Tensorflow 2 版本。

From the error it looks like that the code you want to use is based on Tensorflow 1. You should know that Colab recently removed support for Tf1.从错误看来,您要使用的代码基于 Tensorflow 1。您应该知道 Colab 最近删除了对 Tf1 的支持。 You can still install it manually though.您仍然可以手动安装它。 Just remove the previous Tf2 installation and replace it with the previous version like this:只需删除以前的 Tf2 安装并将其替换为以前的版本,如下所示:

!pip uninstall tensorflow
!pip install tensorflow-gpu==1.15

This is almost always enough (you could be asked to restart the runtime for the change to take effect).这几乎总是足够的(可能会要求您重新启动运行时以使更改生效)。 However, if you experience errors due to the version of Cuda, you could try to re-install cuda and libcudnn too with:但是,如果您因 Cuda 的版本而遇到错误,您也可以尝试重新安装 cuda 和 libcudnn:

!apt install --allow-change-held-packages libcudnn7=7.4.1.5-1+cuda10.0

Update:更新:

After manually installing tensorflow 1 you can remove the instruction %tensorflow_version 1.x , which is called a magic.手动安装 tensorflow 1 后,您可以删除指令%tensorflow_version 1.x ,这被称为魔术。 Before tf1 got discontinued in Colab, that instruction could have been used to activate it instead of doing the installation by hand.在 Colab 中停止使用 tf1 之前,可以使用该指令来激活它,而不是手动进行安装。

Also inside the QuickStart of the repo, it says that you should also install two packages.同样在 repo 的 QuickStart 中,它说您还应该安装两个软件包。 So after the installation of tensorflow add:所以在安装 tensorflow 之后添加:

!pip install tensor2tensor 
!pip install t2t-trainer 

after following the steps above, i encountered this error:完成上述步骤后,我遇到了这个错误:

Loaded runtime CuDNN library: 7.4.1 but source was compiled with: 7.6.0.  CuDNN library major and minor version needs to match or have higher minor version in case of CuDNN 7.0 or later version. If using a binary install, upgrade your CuDNN library.  If building from sources, make sure the library loaded at runtime is compatible with the version specified during compile configuration

Seems like even after installing the compatible cudnn version it doesnt work, how can I work around this issue?似乎即使在安装了兼容的 cudnn 版本后它也不起作用,我该如何解决这个问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM