Python 在 conda 环境中安装 Tensorflow 2.0

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/55392100/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 20:33:52  来源:igfitidea点击:

Install Tensorflow 2.0 in conda enviroment

pythontensorflowconda

提问by polmonroig

I would like to know if anyone knows how can I install tensorflow==2.0.0-alpha0 in a conda enviroment using python 3.7. Is it possible to use python 3.7 or do I have to downgrade to 3.6. Either way what is the command I need to use because the following don't find any package

我想知道是否有人知道如何使用 python 3.7 在 conda 环境中安装 tensorflow==2.0.0-alpha0。是否可以使用 python 3.7 或者我必须降级到 3.6。无论哪种方式,我需要使用什么命令,因为以下找不到任何包

conda install tensorflow==2.0.0-alpha0
conda install tensorflow 
conda install tensorflow=2.0.0-alpha0

I am using fedora 29 and conda 4.6.8 Thanks!

我使用的是 Fedora 29 和 conda 4.6.8 谢谢!

采纳答案by MDah

It could be the case that the package version you want is not available in conda-forge. What you could do is install packages with pip in your conda environment.

可能是您想要的软件包版本在 conda-forge 中不可用。您可以做的是在 conda 环境中使用 pip 安装软件包。

pip install tensorflow==2.0.0-alpha0 

Also the requirements don't state python 3.7, you can try your luck or downgrade to python 3.6.

此外,要求没有说明python 3.7,您可以试试运气或降级到python 3.6。

回答by Agustin Barrachina

TENSORFLOW 2.0 release version is out!

TENSORFLOW 2.0 发布版本发布了!

Since 01/10/2019 I'm not talking beta but the release version.

自 2019 年 1 月 10 日起,我不是在谈论测试版,而是在发布版本。

Using Anaconda (Recommended)

使用 Anaconda(推荐)

Since 01/11/2019 Anaconda is supporting the Tensorflow 2.0.0.

自 2019 年 1 月 11 日起,Anaconda 开始支持 Tensorflow 2.0.0。

Option 1:For what the easiest way is just:

选项 1:对于最简单的方法是什么:

conda install tensorflowor conda install tensorflow-gpu

conda install tensorflow或者 conda install tensorflow-gpu

For the gpu mode, anaconda will take care of all the CUDA everything you need to install for the tensorflow gpu mode to work so I strongly recommend using this method.

对于 gpu 模式,anaconda 会处理所有您需要安装的 CUDA 以便 tensorflow gpu 模式工作,因此我强烈建议使用此方法。

Option 2 (virtual env):It is strongly recommendedto use an environment on where to install tensorflow, for which you need the following command that will create an environment first and then install tensorflow within:

选项2(虚拟ENV):这是强烈建议使用在什么地方安装tensorflow,为此,你需要下面的命令,将首先创建一个环境,然后安装内的tensorflow环境:

  • CPU: conda create -n <your_env_name> tensorflow
  • GPU: conda create -n <your_env_name> tensorflow-gpu
  • 中央处理器: conda create -n <your_env_name> tensorflow
  • 图形处理器conda create -n <your_env_name> tensorflow-gpu

Change <your_env_name>by a meaningful name like tf-2

更改<your_env_name>为有意义的名称,例如tf-2

To use tensorflow run first conda activate <your_env_name>

首先使用 tensorflow 运行 conda activate <your_env_name>

Using pip

使用点子

Using pip the tensorflow official instructionsare quite complete.

使用 pip tensorflow官方说明已经很完整了。

Just install tensorflow using pip like:

只需使用 pip 安装 tensorflow,例如:

# Current stable release for CPU-only
pip install tensorflow

I yet recommend before doing everything to install tensorflow in a new environment so the 3 steps would be (with anaconda):

我还建议在做任何事情之前在新环境中安装 tensorflow,所以 3 个步骤是(使用 anaconda):

conda create --n <our_env_name> pip
conda activate <your_env_name>
pip install tensorflow

Now for the GPU version it's harder with pip, I recommend you this link

现在对于 GPU 版本,pip 更难,我推荐你这个链接

回答by davidrpugh

You can now install TF2 for Python 3.7 using conda. You can run the usual

您现在可以使用 conda 为 Python 3.7 安装 TF2。你可以运行通常的

$ conda install tensorflow=2.0 python=3.7

or

或者

$ conda install tensorflow-gpu=2.0 python=3.7

for the GPU version.

对于 GPU 版本。

My preferred approach however would be to manage the dependencies using an environment.ymlfile. You can find examples of how to do this for TF2 and dependencies in these template repos that I created on GitHub.

然而,我的首选方法是使用environment.yml文件管理依赖项。您可以在我在 GitHub 上创建的这些模板存储库中找到有关如何为 TF2 和依赖项执行此操作的示例。

https://github.com/kaust-vislab/tensorflow-cpu-data-science-project

https://github.com/kaust-vislab/tensorflow-cpu-data-science-project

https://github.com/kaust-vislab/tensorflow-gpu-data-science-project

https://github.com/kaust-vislab/tensorflow-gpu-data-science-project

回答by inferno

The problem is in conda install tensorflow.

问题出在conda install tensorflow.

condadoes not have tensorflow. You will require to install tensorflowusing pip. You do notneed to downgrade your Python. It will work with Python 3.7.

conda没有tensorflow。您将需要tensorflow使用pip. 你并不需要降级你的Python。它将与 Python 3.7 一起使用。

Use this

用这个

$ pip install --upgrade tensorflow==2.0.0-beta0

$ pip install --upgrade tensorflow==2.0.0-beta0

Since the beta0version is released, I mentioned that. You can choose other tf version.

自从beta0版本发布以来,我提到了这一点。您可以选择其他 tf 版本。

I recommend going through this post on TowardsDataScience: Step-by-Step Guide to Install Tensorflow 2.0.

我建议阅读 TowardsDataScience: Step-by-Step Guide to Install Tensorflow 2.0上的这篇文章。

This post covers installation steps with conda.

这篇文章介绍了使用conda.

回答by jgoday

You might want to take a look at this link: https://pypi.org/project/tf-nightly-2.0-preview/#filesto see which python version and OS supports your package

您可能想查看此链接:https: //pypi.org/project/tf-nightly-2.0-preview/#files以查看哪个 python 版本和操作系统支持您的包

enter image description here

enter image description here

回答by QaraQoyunlu

I tried to install tensorflow v2 with conda install tensorflowor conda install tensorflow-gpuonly to get lots of incompatible dependencies.

我试图安装 tensorflow v2conda install tensorflowconda install tensorflow-gpu仅获得许多不兼容的依赖项。

Just run

赶紧跑

pip install -upgrade tensorflow-gpu

pip install -upgrade tensorflow-gpu

or

或者

pip install tensorflow-gpu=2.0.0for a specific version

pip install tensorflow-gpu=2.0.0对于特定版本