安装mingw+Theano+keras

  • 一、关于深度学习框架TensorFlow、Theano 和 Keras
  • 二、可以安装theano、keras的python版本
  • 三、安装mingw+Theano+keras
    • 1. 进入cmd,创建虚拟环境keras:
    • 2. 进入虚拟环境keras:
    • 3.安装 mingw 和 libpython :
    • 4. 安装theano:
    • 5. 安装keras:
    • 6. 检验是否安装成功:
      • 1. 进入python,使用`import theano`检验theano是否安装成功:
        • 警告解决方法:
      • 2. theano.test()检验theano是否真的安装成功:
      • 3.如果用高于3.5.X的python环境进行安装, theano.test()时会出现以下错误,并附带解决办法:
        • 错误解决方法:
  • 参考链接

一、关于深度学习框架TensorFlow、Theano 和 Keras

https://www.cnblogs.com/shenxiaolin/p/11121152.html

Keras 可以基于两个Backend(也就是Keras 基于什么东西来做运算):
一个是 Theano,一个是 Tensorflow(默认)。可以通过修改Backend将默认的Tensorflow改为Theano。
如果我们选择Theano作为Keras的Backend, 那么Keras就用 Theano 在底层搭建你需要的神经网络;
同样,如果选择 Tensorflow 的话呢,Keras 就使用 Tensorflow 在底层搭建神经网络。

二、可以安装theano、keras的python版本

theano、keras兼容的python版本:

 - theano -> python[version='>=2.7,<2.8.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.6,<3.7.0a0|>=3.5,<3.6.0a0']
 - keras -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0']

我们选择python3.5进行安装。

三、安装mingw+Theano+keras

1. 进入cmd,创建虚拟环境keras:

至于需要创建虚拟环境的原因,请参见文章:Anaconda、Jupyterlab、虚拟环境、Kernel

conda create --name keras python=3.5

2. 进入虚拟环境keras:

conda activate keras

3.安装 mingw 和 libpython :

conda install mingw libpython

报错:

PackagesNotFoundError: The following packages are not available from current channels:- mingwCurrent channels:- https://repo.anaconda.com/pkgs/msys2/win-64- https://repo.anaconda.com/pkgs/msys2/noarch- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/win-64- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/noarch- https://repo.anaconda.com/pkgs/main/win-64- https://repo.anaconda.com/pkgs/main/noarch- https://repo.anaconda.com/pkgs/r/win-64- https://repo.anaconda.com/pkgs/r/noarchTo search for alternate channels that may provide the conda package you are looking for, navigate tohttps://anaconda.organd use the search bar at the top of the page.

解决:

anaconda search -t conda mingw

显示:

Using Anaconda API: https://api.anaconda.org
C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warningsInsecureRequestWarning)
Packages:Name                      |  Version | Package Types   | Platforms       | Builds------------------------- |   ------ | --------------- | --------------- | ----------RMG/mingwpy               |    0.1.0 | conda           | win-32, win-64  | py27_3: GCC for Windows 64 & 32 bitsbcilab/qt_mingw_32_release |   5.15.0 | conda           | win-32          | 0bcilab/qt_mingw_64_release |   5.15.0 | conda           | win-64          | 0bcilab/resonance_beta_mingw_32 |    3.3.1 | conda           | win-32          | 103bcilab/resonance_mingw_32 |    3.4.1 | conda           | win-32          | 11, 13, 138, 20, 0, 79, 18, 27, 23, 28, 132, 131, 89, 72, 134, 80, 78, 86, 87, 84, 85bcilab/resonance_mingw_64 |    3.4.1 | conda           | win-32, win-64  | 25, 27, 20, 18, 28, 0, 2, 4conda-forge/mingwpy       |    0.1.0 | conda           | win-32, win-64  | py27_2, py34_1, py34_0, py27_0, py27_1, py35_0, py34_2: GCC for Windows 64 & 32 bitsfree/mingw                |      4.7 | conda           | win-32, win-64  | 1, 0ijstokes/mingwpy          |   v0.1.0 | conda           | win-64          | 0.1.0lucaszw/mingw-runtime     |      4.7 | conda           | win-32          | 0mfix/libboost-mingw       |   1.67.0 | conda           | win-64          | 1mwm126/libboost-mingw     |   1.65.1 | conda           | win-64          | 1, 0mwojcikowski/mingwpy      |    0.1.0 | conda           | win-32, win-64  | py34_2, py34_1, py34_0, py27_0, py27_1, py35_0, py27_2: GCC for Windows 64 & 32 bitsomnia/mingwpy             |    0.1.0 | conda           | win-32, win-64  | py27_3, py36_3, py34_3, py33_3: GCC for Windows 64 & 32 bitstakluyver/mingw-w64       |  3.1.0.1 | conda           | linux-64        | 0tz-lom/qt_mingw_64_release |          | conda           | win-64          | 0tz-lom/resonance_mingw_32 |          | conda           | win-32          | 139tz-lom/resonance_mingw_64 |          | conda           | win-64          | 27ukoethe/mingw             |          | conda           | win-64          | 0, vc11ukoethe/mingw-for-msvc    |    4.7.2 | conda           | win-64          | 0: Configure MinGW as a subtool of Visual Studio (needed to compile packages that MSVC can't handle, e.g. Fortran sources)ukoethe/mingw-for-msvc-build |    4.7.2 | conda           | win-64          | 0: Configure MinGW as a subtool of Visual Studio (needed to compile packages that MSVC can't handle, e.g. Fortran sources)wheeler-microfluidics/mingw-runtime |      4.7 | conda           | win-32          | 0wheeler-microfluidics/tdm-mingw |  1.908.0 | conda           | win-32          | 1willyd/openblas-mingw     |   0.2.14 | conda           | win-64          | 0
Found 24 packagesRun 'anaconda show <USER/PACKAGE>' to get installation details

选择一个从上述路径中选一个可行的路径再次安装:例如选择 free/mingw | 4.7 | conda | win-32, win-64 | 1, 0

conda install -c https://conda.anaconda.org/free mingw

安装libpython:

conda install libpython

查看是否成功:

g++ --versiong++.exe (GCC) 4.7.0 20111220 (experimental)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

4. 安装theano:

conda install theano

有可能会出现连接失败的问题,重试即可。

5. 安装keras:

conda install keras

6. 检验是否安装成功:

1. 进入python,使用import theano检验theano是否安装成功:

(keras) C:\Users\huipu>python
Python 3.8.11 (default, Aug  6 2021, 09:57:55) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

出现了警告:Using NumPy C-API based implementation for BLAS functions.

警告解决方法:

a. 第一步:安装三个包

#在环境中安装这三个包
conda install mkl
conda install mkl-service
conda install blas

b. 第二步:在用户目录下放置一个文件
在桌面新建一个txt文档,输入如下内容:

#我建的是这个
[blas]
ldflags=-lmkl_rt

或者输入如下内容:

[blas]
ldflags=-lblas

将文档另存为文件名:.theanorc.txt ,文档类型为:所有文件(.) 。文件的存放路径为:C:\Users\你的电脑用户名 。

c. 验证,再次import theano就没有警告啦!

(keras) C:\Users\huipu>python
Python 3.8.11 (default, Aug  6 2021, 09:57:55) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
>>> print (theano.config.blas.ldflags)
-lmkl_rt

2. theano.test()检验theano是否真的安装成功:

虽然现在import成功了。但是,大佬都用theano.test()来检验theano是否真的安装成功,即使出现了一堆错误,但是如果出现default=0 的话,就说明安装成功了~ ~

去python里theano.test():

(keras)C:\Users\huipu>python
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
>>> theano.test()
Theano version 1.0.2
theano is installed in C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano
NumPy version 1.14.2
NumPy relaxed strides checking option: True
NumPy is installed in C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\numpy
Python version 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)]
nose version 1.3.7
EE...........E.EE.....EEEE....E..................................C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano\gof\vm.py:887: UserWarning: CVM does not support memory profile, using Stack VM.'CVM does not support memory profile, using Stack VM.')
.E.........SS.............0.7415943278643314
0.7415943278643314
0.7415943278643314
0.7415943278643314
....E...E.....EEEEE..E......................................E...................................................E......................EC:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano\gof\vm.py:890: UserWarning: LoopGC does not support partial evaluation, using Stack VM.'LoopGC does not support partial evaluation, '
.C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano\gof\vm.py:890: UserWarning: LoopGC does not support partial evaluation, using Stack VM.'LoopGC does not support partial evaluation, '
C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano\gof\vm.py:890: UserWarning: LoopGC does not support partial evaluation, using Stack VM.'LoopGC does not support partial evaluation, '
.....EEEESEEEEEEEESEEEES.C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano\gpuarray\type.py:895: UserWarning: config.experimental.unpickle_gpu_on_cpu is set to True. Unpickling GpuArray as numpy.ndarray"config.experimental.unpickle_gpu_on_cpu is set to True. "
.EEEEEES.....SEE...C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano\sandbox\rng_mrg.py:1031: UserWarning: MRG_RandomStreams.multinomial_wo_replacement() is deprecated and will be removed in the next release of Theano. Please use MRG_RandomStreams.choice() instead.warnings.warn('MRG_RandomStreams.multinomial_wo_replacement() is '
.C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano\sandbox\rng_mrg.py:1031: UserWarning: MRG_RandomStreams.multinomial_wo_replacement() is deprecated and will be removed in the next release of Theano. Please use MRG_RandomStreams.choice() instead.warnings.warn('MRG_RandomStreams.multinomial_wo_replacement() is '
...EES..E....E.......EEEE.EEEEEEEEEEEEEEEEEEEE.....EEEEE...E....E..E..S.....EEEEEEEEE......EEE......EEEE..........SEE..SSSS.......S.....E...
======================================================================
ERROR: Failure: ImportError (No module named 'parameterized')
======================================================================
ERROR: test_nnet (theano.compile.tests.test_misc.TestNnet)
======================================================================
ERROR: theano.compile.tests.test_mode.test_no_output_from_implace
======================================================================
ERROR: theano.compile.tests.test_monitormode.test_not_inplace
======================================================================
ERROR: theano.compile.tests.test_nanguardmode.test_NanGuardMode
======================================================================
ERROR: test_input_aliasing_affecting_inplace_operations (theano.compile.tests.test_pfunc.Test_aliasing_rules)
======================================================================
ERROR: test_partial_input_aliasing_affecting_inplace_operations (theano.compile.tests.test_pfunc.Test_aliasing_rules)
======================================================================
ERROR: test_profiling (theano.compile.tests.test_profiling.Test_profiling)
======================================================================
ERROR: test_constant (theano.gof.tests.test_compute_test_value.TestComputeTestValue)
======================================================================
ERROR: test_ndarray (theano.gof.tests.test_compute_test_value.TestComputeTestValue)
======================================================================
ERROR: test_scan_err2 (theano.gof.tests.test_compute_test_value.TestComputeTestValue)
======================================================================
ERROR: test_shared (theano.gof.tests.test_compute_test_value.TestComputeTestValue)
======================================================================
ERROR: test_string_var (theano.gof.tests.test_compute_test_value.TestComputeTestValue)
======================================================================
ERROR: test_variable_only (theano.gof.tests.test_compute_test_value.TestComputeTestValue)
======================================================================
ERROR: test_node_outputs_not_used (theano.gof.tests.test_fg.TFunctionGraph)
======================================================================
ERROR: theano.gof.tests.test_link.test_sort_schedule_fn
======================================================================
ERROR: theano.gof.tests.test_vm.test_partial_function
======================================================================
ERROR: Demonstrate stochastic gradient descent optimization for a multilayer
======================================================================
ERROR: theano.tensor.tests.test_misc.test_bug_2009_07_17_borrowed_output
----------------------------------------------------------------------
Ran 413 tests in 32.590sFAILED (SKIP=15, errors=101)
<nose.result.TextTestResult run=413 errors=101 failures=0>

我的确出现了这么一大堆错误,但是我也没看到default=0字样。
未完待续。。。

3.如果用高于3.5.X的python环境进行安装, theano.test()时会出现以下错误,并附带解决办法:

这是之前在Python 3.8环境中进行安装时发生的错误:

(theano) C:\Users\huipu>python
Python 3.8.11 (default, Aug  6 2021, 09:57:55) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
>>> theano.test()
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "C:\ProgramData\Anaconda3\envs\theano\lib\site-packages\theano\__init__.py", line 148, in testraise ImportError("The nose module is not installed."
ImportError: The nose module is not installed. It is needed for Theano tests.

test()出错了:提示nose模块没有安装。

错误解决方法:

不慌,首先我们来看看我们安装nose了没:

pip listconda list查看了一下,列表里都显示已安装nose 1.3.7。而且在python里单独import nose没出错:

(theano) C:\Users\huipu>python
Python 3.8.11 (default, Aug  6 2021, 09:57:55) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import nose
>>> nose
<module 'nose' from 'C:\\ProgramData\\Anaconda3\\envs\\theano\\lib\\site-packages\\nose\\__init__.py'>
>>> result=nose.run()----------------------------------------------------------------------
Ran 0 tests in 0.069sOK

所以我不由得怀疑:可能nose 1.3.7和当前的python环境3.8.11不兼容???

  1. 所以我先尝试升级nose包:conda update nose,升级完之后仍然是1.3.7版本。升级nose行不通。
  2. 既然nose升不了,那就降级python吧:Currently, Theano Release 1.0 only supports >=3.4 and < 3.6. If your Python version is higher than 3.5.X, try downgrading and then re-run the Theano test. Do let everyone know if that works.
    重新安装一个3.5.X版本的python,就是重复之前的步骤就好。
  3. 再去test(),发现错误:没有nose模块。解决:安装nose模块。
(keras) C:\Users\huipu>python
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
>>> theano.test()
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "C:\ProgramData\Anaconda3\envs\theano_2\lib\site-packages\theano\tests\main.py", line 107, in testfrom nose.config import Config
ImportError: No module named 'nose'
#安装nose模块
conda install nose

装好之后,再去test(),会发现之前的ImportError: The nose module is not installed. It is needed for Theano tests.这个错误消失了!!!
说明降级python是有效的。不能用太高版本的python安装theano。


参考链接

WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

安装mingw+Theano+keras(多警告、错误解决办法)相关推荐

  1. Oracle19c安装教程及PLSQL配置常见错误解决办法

    本人电脑上也装了不少比较难以安装的程序,而且也亲身破解了一些软件,自己以前也安装过MySQL和DB2,原以为Oracle也差不多,直到我亲身经历了,我才知道什么是痛苦.帅帅本人在经历了长时间的折磨之后 ...

  2. 安装完PLSQL遇到Initialization error错误解决办法

    问题描述: 当安装完PLSQL或者免安装版的时候打开PLSQL弹框报Initialization error错 主要原因是没有相应的oci.dll文件 解决办法: 1:在PLSQL配置>首选项中 ...

  3. VS2010安装Nuget提示签名不匹配错误解决办法

    1.到vs2010的扩展文件夹下面把这个Nuge Package Manager文件夹给干掉: C:\Program Files\Microsoft Visual Studio 10.0\Common ...

  4. sql安装错误解决办法

    安装 sql2000 ,提示如下错误解决办法"a previous program installation created pending file operation on the in ...

  5. PHP编译安装时常见错误解决办法,php编译常见错误

    PHP编译安装时常见错误解决办法,php编译常见错误 1.configure: error: xslt-config not found. Please reinstall the libxslt & ...

  6. 安装kilo版本openstack-dashboard时出现的python compress command not found错误解决办法

    2019独角兽企业重金招聘Python工程师标准>>> 安装openstack-dashboard时出现的python compress command not found错误解决办 ...

  7. linux libvpx编译安装,linux编译安装时常见错误解决办法

    **configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution** 复 ...

  8. linux源码安装php缺少动态库,php源代码安装常见错误解决办法

    php源代码安装常见错误解决办法 错误:configure: error: libevent >= 1.4.11 could not be found 解决:yum -y install lib ...

  9. linux编译安装的报错,linux编译安装时常见错误解决办法

    This article is post on https://coderwall.com/p/ggmpfa 原文链接:http://www.bkjia.com/PHPjc/1008013.html ...

最新文章

  1. 前端基础入门第一阶段-Web前端开发基础环境配置
  2. mobaxterm 传文件夹_如何使用MobaXterm上传文件到远程Linux系统-MobaXterm使用教程
  3. Play! Framework 系列(三):依赖注入
  4. Google、Facebook、GitHub、Babel核心成员齐聚,第13届D2前端技术论坛正式启动
  5. Mysql学习总结(21)——MySQL数据库常见面试题
  6. SharePoint2010部署(一)---数据库的安装
  7. iOS平台下闪退原因汇总(一):Ran out of trampolines of type 0/1/2 运行时间错误
  8. 一起谈.NET技术,在.NET中嵌入IronPython 交互
  9. 2011年SSCI收录信息科学与图书馆学学科期刊86种
  10. vue开发很难?不存在的,可视化开发神器mxdev0.4版更新
  11. 识别中文_文字的效率:中英韩日四国文字识别效率对比,中文遥遥领先
  12. php通过身份证判断性别
  13. 虚拟空间、vps、管理型服务器和独立主机之间那些事儿
  14. 沉淀+树脂吸附工艺为铅酸电池废水处理提供新思路
  15. 蓝桥杯算法提高试题 学霸的迷宫(BFS)
  16. Android直播开发之旅(15):libjpeg库的编译移植与使用
  17. 瞬态抑制二极管TVS的基本知识
  18. R语言,导入XLSX的Excel数据 多sheet
  19. ibm 服务器 总显示f1,联想ThinkPad笔记本中F1/F4键盘指示灯一直常亮着如何解决
  20. Module 模块化

热门文章

  1. 论斯芬克司吃人的合理性。
  2. uni-app 实现拨打电话功能(android)
  3. Mixly23:U型红外光电开关
  4. 电子数据取证-Raid重组
  5. 快速排序 php内存超限,数据结构与算法设计
  6. 如何选择最适合自己的地图软件
  7. 厦门理工学院OJ题解(1139:秦心的面具)
  8. 半导体物理——PN结
  9. 选择一款舒心的MD编辑器
  10. 成功解决LINK : fatal error LNK1181: 无法打开输入文件“avdevice.lib” error: command 'D:\\Program Files (x86)\\Micr