如何在Google Colab上安装TensorFlow的旧版本?

我在Google Colab上使用!pip uninstall tensorflow -y!pip uninstall tensorflow-gpu -y卸载了预装的TensorFlow版本。然后我安装了所需的版本!pip install tensorflow-gpu==1.4.1,看起来安装成功了,输出了Successfully installed tensorflow-gpu-1.4.1。然而,当我运行!pip show tensorflow时,我得到了警告:未找到包:tensorflow。

我已经尝试在安装TensorFlow后重启运行时,但这不起作用。我也在使用GPU运行时。

此外,当我运行以下代码时:

import tensorflow as tfprint(tf.__version__)

我得到了以下错误:

---------------------------------------------------------------------------ImportError                               Traceback (most recent call last)/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()     57 ---> 58   from tensorflow.python.pywrap_tensorflow_internal import *     59   from tensorflow.python.pywrap_tensorflow_internal import __version__10 framesImportError: libcublas.so.8.0: cannot open shared object file: No such file or directoryDuring handling of the above exception, another exception occurred:ImportError                               Traceback (most recent call last)/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()     70 for some common reasons and solutions.  Include the entire stack trace     71 above this error message when asking for help.""" % traceback.format_exc()---> 72   raise ImportError(msg)     73      74 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-longImportError: Traceback (most recent call last):  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>    from tensorflow.python.pywrap_tensorflow_internal import *  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>    _pywrap_tensorflow_internal = swig_import_helper()  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)  File "/usr/lib/python3.6/imp.py", line 243, in load_module    return load_dynamic(name, filename, file)  File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic    return _load(spec)ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directoryFailed to load the native TensorFlow runtime.See https://www.tensorflow.org/install/install_sources#common_installation_problemsfor some common reasons and solutions.  Include the entire stack traceabove this error message when asking for help.---------------------------------------------------------------------------NOTE: If your import is failing due to a missing package, you canmanually install dependencies using either !pip or !apt.To view examples of installing some common dependencies, click the"Open Examples" button below.---------------------------------------------------------------------------

我该如何解决这个问题以正确安装TensorFlow 1.4.1?我已经尝试在安装TensorFlow后重启运行时,但这不起作用。我也在使用GPU运行时。


回答:

尝试使用以下命令重新安装TensorFlow

!pip uninstall tensorflow -y!pip install  tensorflow==1.14

然后在Colab提示时重启运行时。你应该能够导入正确的TensorFlow版本。

%tensorflow_version 1.ximport tensorflow as tfprint(tf.__version__)1.14.0

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注