简体   繁体   English

即使已经安装了tensorflow-gpu,带有keras软件包的conda bug也会安装tensorflow

[英]conda bug with keras package installs tensorflow even if tensorflow-gpu is already installed

I wanted share a problem I encountered and the solution I found that worked on my system. 我想分享我遇到的问题,以及发现的解决方案可在我的系统上使用。

For reference, this is my environment: Ubuntu 16.04 64-bit, nVidia GPU, conda 4.5.2 作为参考,这是我的环境:Ubuntu 16.04 64位,nVidia GPU,conda 4.5.2

I created a conda virtual environment and installed tensorflow-gpu (which resulted in 1.7.0 being installed which is not the latest, but is fine for my purposes). 我创建了一个conda虚拟环境,并安装了tensorflow-gpu(这导致安装了1.7.0,这不是最新的,但对我而言很合适)。

I then did $ conda install keras 然后我做了$ conda install keras

keras was installed correctly, BUT it also installed tensorflow non-gpu version, which I cannot use. keras安装正确,但是它也安装了tensorflow non-gpu版本,我无法使用。

This seems like a dependency bug in which keras package does not recognize tensorflow-gpu package as installed. 这似乎是一个依赖性错误,其中keras软件包无法识别已安装的tensorflow-gpu软件包。

I was forced to remove tensorflow (non-gpu package) and to use 我被迫删除tensorflow(非gpu包)并使用

$ python3.6 -m pip install keras

This worked, but I would rather have consistent conda managed packages. 这行得通,但是我宁愿拥有一致的conda托管软件包。

I hope that Anaconda fixes this, but in the meantime, you can try my solution. 我希望Anaconda可以解决此问题,但与此同时,您可以尝试我的解决方案。

BTW, don't even get me started on why I couldn't just use pip or pip3 instead of "python3.6 -m pip". 顺便说一句,甚至不让我开始为什么我不能只使用pip或pip3而不是“ python3.6 -m pip”。 Python 3.6 and 3.5 on Ubuntu at least are at war with each other causing all kinds of "module not found" problems. 至少Ubuntu上的Python 3.6和3.5相互冲突,从而导致各种“模块未找到”问题。 But that's for another post. 但这是另一篇文章。

You can try keras-gpu 您可以尝试keras-gpu

conda install -c anaconda keras-gpu

Where -c anaconda indicates a channel where to look for the package. 其中-c anaconda指示查找软件包的通道。 (You may want to try the default conda install keras-gpu or if you know about other channels, use them). (您可能要尝试使用默认的conda install keras-gpu或者如果您知道其他渠道,请使用它们)。


About python versions conflicting, it's a good idea to create specific environments, so you can also try different versions of tensorflow + keras without conflicts. 关于python版本冲突,创建特定环境是一个好主意,因此您也可以尝试不同版本的tensorflow + keras而不会发生冲突。

On my machine, using the intel version of python was a great deal for processing speed (although you're going to use GPU, not my case) 在我的机器上,使用intel版本的python对于处理速度有很大的帮助(尽管您将使用GPU,而不是我的情况)

Create a new environment: 创建一个新环境:

#anaconda version
conda create -n yourenvname python=x.x anaconda

#intel version
conda create -n yourenvname intelpython3_core python=3
    #can also be specific, like python=3.5

Then you activate your environment: 然后激活环境:

source activate yourenvname

And install and use everything with this environment activated. 并在激活此环境的情况下安装和使用所有内容。

If using intel Python, it's interesting to follow the rest of the process here to use the optimized intel distributions of numpy, scipy and others: https://software.intel.com/en-us/articles/using-intel-distribution-for-python-with-anaconda 如果使用英特尔Python,有趣的是按照此处的其余过程使用numpy,scipy和其他代码的优化的英特尔发行版: https ://software.intel.com/zh-cn/articles/using-intel-distribution- 与蟒蛇的蟒蛇

More info on environments: https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/ 有关环境的更多信息: https : //uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/

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

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