Python 如何降级 tensorflow,可能有多个版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45749992/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to downgrade tensorflow, multiple versions possible?
提问by Yee
I have tensorflow 1.2.1 installed, and I need to downgrade it to version 1.1 to run a specific tutorial. What is the safe way to do it? I am using windows 10, python 3.5. Tensorflow was installed with pip3, but "pip3 show tensorflow" returns blank.
我安装了 tensorflow 1.2.1,我需要将其降级到 1.1 版才能运行特定教程。什么是安全的方法呢?我正在使用 Windows 10,python 3.5。Tensorflow 与 pip3 一起安装,但“pip3 show tensorflow”返回空白。
Is it possible to have multiple version of tensorflow on the same OS?
是否可以在同一操作系统上拥有多个版本的 tensorflow?
回答by Jürg Merlin Spaak
Pip allows to specify the version
Pip 允许指定版本
pip install tensorflow==1.1
pip install tensorflow==1.1
回答by Yee
I discovered the joy of anaconda: https://www.continuum.io/downloads
我发现了anaconda的乐趣:https: //www.continuum.io/downloads
C:> conda create -n tensorflow1.1 python=3.5
C:> activate tensorflow1.1
(tensorflow1.1)
C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl
voila, a virtual environment is created.
瞧,创建了一个虚拟环境。
回答by GeertH
Is it possible to have multiple version of tensorflow on the same OS?
是否可以在同一操作系统上拥有多个版本的 tensorflow?
Yes, you can use python virtual environments for this. From the docs:
是的,您可以为此使用 python 虚拟环境。从文档:
A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.
虚拟环境是一种工具,通过为它们创建虚拟 Python 环境,将不同项目所需的依赖项保存在不同的位置。它解决了“项目 X 依赖于 1.x 版本,但项目 Y 需要 4.x”的困境,并使您的全局站点包目录保持清洁和可管理。
After you have install virtualenv (see the docs), you can create a virtual environment for the tutorial and install the tensorflow version you need in it:
安装 virtualenv 后(请参阅文档),您可以为教程创建一个虚拟环境并在其中安装您需要的 tensorflow 版本:
PATH_TO_PYTHON=/usr/bin/python3.5
virtualenv -p $PATH_TO_PYTHON my_tutorial_env
source my_tutorial_env/bin/activate # this activates your new environment
pip install tensorflow==1.1
PATH_TO_PYTHON
should point to where python is installed on your system.
When you want to use the other version of tensorflow execute:
PATH_TO_PYTHON
应该指向系统上安装 python 的位置。当你想使用其他版本的 tensorflow 时,执行:
deactivate my_tutorial_env
Now you can work again with the tensorflow version that was already installed on your system.
现在您可以再次使用系统上已安装的 tensorflow 版本。
回答by Omkar
If you are using python3 on windows then you might do this as well
如果您在 Windows 上使用 python3,那么您也可以这样做
pip3 install tensorflow==1.4
pip3 install tensorflow==1.4
you may select any version from "(from versions: 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0)"
您可以从“(从版本:1.2.0rc2、1.2.0、1.2.1、1.3.0rc0、1.3.0rc1、1.3.0rc2、1.3.0、1.4.0rc0、1.4.0rc1、1.4.0 , 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0)"
I did this when I wanted to downgrade from 1.7 to 1.4
当我想从 1.7 降级到 1.4 时,我这样做了
回答by Hyman Chan
You can try to use the options of --no-cache-dir
together with -I
to overwrite the cache of the previous version and install the new version. For example:
你可以尝试使用的选项--no-cache-dir
连同-I
覆盖的以前版本的缓存并安装新版本。例如:
pip3 install --no-cache-dir -I tensorflow==1.1
Then use the following command to check the version of tensorflow:
然后使用以下命令检查tensorflow的版本:
python3 -c ‘import tensorflow as tf; print(tf.__version__)'
It should show the right version got installed.
它应该显示安装了正确的版本。
回答by Mike Zhang
You can just install desired version and conda will automatically downgrade the current package for you.
您只需安装所需的版本,conda 就会自动为您降级当前的软件包。
conda install tensorflow=1.1