简体   繁体   English

在Anaconda中安装Keras的问题

[英]Problem with Keras installation in Anaconda

I'm trying to install Keras in anaconda from the instructions given here . 我正试图按照这里给出的说明在anaconda中安装Keras。

I ran the command conda install -c conda-forge keras and then after that, I pressed y when the prompt appeared asking me to press y/n. 我跑的命令conda install -c conda-forge keras并在那之后,我按下y时系统会提示要求我按Y / N。 Then some libraries were downloaded and immediately after that the anaconda prompt crashed. 然后下载了一些库,紧接着之后anaconda提示崩溃了。

I looked at this thread and I couldn't try installing it using pip because every time I activate the environment, it crashes in a few seconds after automatically running the following commands: 我查看了这个线程,我无法尝试使用pip安装,因为每次激活环境时,它会在自动运行以下命令后几秒内崩溃:

C:\Users\ashut>python C:\Users\ashut\Anaconda3\envs\py36\etc\keras\load_config.py  1>temp.txt

C:\Users\ashut>set /p KERAS_BACKEND= 0<temp.txt

C:\Users\ashut>del temp.txt

C:\Users\ashut>python -c "import keras"  1>nul 2>&1

I could barely manage to get a screenshot of the error that is generated after the commands given above are executed. 我几乎无法获得执行上面给出的命令后生成的错误的屏幕截图。 I don't know what's happening here: 我不知道这里发生了什么:

在此输入图像描述

And then it crashes. 然后它崩溃了。

I expected at least the instructions on anaconda's own site to be reliable, but sadly this doesn't seems to be the case. 我预计至少在anaconda自己的网站上的说明是可靠的,但遗憾的是这似乎并非如此。 If there's any other method to install Keras in anaconda without losing this environment, I'd be more than grateful to know. 如果有任何其他方法在anaconda中安装Keras而不会失去这种环境,我会非常感激地知道。

You are missing build tools. 您缺少构建工具。 Anaconda depends on their presence and it cannot supply them by itself, as these are proprietary Microsoft tools. Anaconda依赖于它们的存在,它不能自己提供它们,因为它们是专有的Microsoft工具。 To fix the problem install them from here . 要解决此问题,请从此处安装。 After you reboot your computer, Anaconda should work just fine. 重新启动计算机后,Anaconda应该可以正常工作。

pip works for you since it takes a binary, it does not compile it. pip适合你,因为它需要一个二进制文件,它不会编译它。 It's suboptimal and in case of deep learning performance is important. 它不是最理想的,在深度学习的情况下,性能很重要。 Check eg this article to learn about differences between conda and pypi tensorflow. 检查例如本文以了解conda和pypi tensorflow之间的差异。

Nothing worked actually. 实际上没有任何效果。 I tried deleting the environment in which I installed Keras, but even deleting it and creating an environment with another name, the same four statements were automatically executed and crashed the anaconda prompt, as before. 我尝试删除我安装Keras的环境,但即使删除它并创建一个具有其他名称的环境,也会自动执行相同的四个语句并像以前一样崩溃anaconda提示符。

So I reinstalled Anaconda, again made an environment for python 3.6, and installed tensorflow-gpu and keras using pip . 所以我重新安装了Anaconda,再次为python 3.6创建了一个环境,并使用pip安装了tensorflow-gpu和keras。 I don't know why but it worked this time. 我不知道为什么,但这次它起作用了。

Edit 1: I found this after I'd performed the steps described above. 编辑1: 我在执行上述步骤后发现了这一点 This thread also concentrates on reinstalling Anaconda, as no solution to such an event is known yet. 该线程还专注于重新安装Anaconda,因为尚未知道此类事件的解决方案。

Edit 2: Okay I think I figured out what the problem was. 编辑2: 好的,我想我弄清楚问题是什么。 I had the wrong version of CUDA installed - CUDA 10, which is not yet supported by tensorflow and hence keras showed problems. 我安装了错误版本的CUDA - CUDA 10,这还没有被tensorflow支持,因此keras显示出问题。 So this time, I installed CUDA 9 and it's corresponding CuDNN version, uninstalled the pip versions of tensorflow & keras and installed them again using conda . 所以这一次,我安装CUDA 9和它对应CuDNN版本,卸载了pip tensorflow&keras的版本,并再次安装使用它们conda It worked, without a hitch. 它工作顺利,没有任何障碍。

TL;DR : TL; DR

The following works on CUDA 9, CuDNN 7.4.2 以下适用于CUDA 9,CuDNN 7.4.2

pip uninstall tensorflow-gpu
pip uninstall keras

conda install tensorflow-gpu
conda install keras-gpu

Read Lucasz's answer for why I uninstalled the pip versions. 阅读Lucasz的答案,解释为什么我卸载了pip版本。

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

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