如何在 google colab 中降级到 tensorflow-gpu 1.12 版

Gay*_*ppu 9 downgrade tensorflow google-colaboratory

我正在运行一个 GAN,它只与旧版本的 tensorflow GPU 兼容,所以我需要将 tensorflow gpu 从 google colab 中的 1.15 降级到 1.12。我尝试使用此线程中建议的以下命令。

%tensorflow_version 1.x
import tensorflow as tf
print(tf.__version__)

!nvcc --version
Run Code Online (Sandbox Code Playgroud)

在魔术和版本检查(我现在得到 tensorflow 版本 == 1.15.2)之后,我安装在下面。安装 tensorflow ==1.12.2 后,我按照他们的建议重新启动运行时(我也尝试过其他方式)并安装 cuda 并再次重新启动运行时(此处也尝试过其他方式)。

!pip install tensorflow-gpu==1.12.2

!wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
!dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
!apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
!apt-get update
!apt-get install cuda=9.0.176-1
Run Code Online (Sandbox Code Playgroud)

这种方式一直有效到 2019 年,但现在对我不起作用。我需要使用 pip 或不使用 pip 的解决方案。

我也尝试了下面的代码来卸载当前版本并安装 1.12 但它没有用。而且我知道 colab 不建议使用 pip 安装 tensorflow。

!pip uninstall tensorflow-gpu -y
Run Code Online (Sandbox Code Playgroud)

小智 0

!pip uninstall tensorflow
!pip install tensorflow-gpu==1.12.0
import tensorflow as tf
print(tf.__version__)
Run Code Online (Sandbox Code Playgroud)