[关闭]
@Wayne-Z 2016-07-27T15:03:45.000000Z 字数 3570 阅读 3985

Win10系统下搭建深度学习环境(一)

Deep-Learning theano


这是楼主学习在windows下搭建深度学习环境的心(作)路(死)历程,本着no zuo no die 的精神,小白楼主坚持不懈地折腾了一整天,留此文章,以供后人参考(其实就是怕万一重装了系统又得从头再来)。

首战

安装Anaconda

直接点击进入链接
注意安装的过程中可以让anaconda将原有版本的python给删去,无所谓的。

安装Theano

这个时候你会发现Numpy和Scipy等都已经自动装好,因此只需要进入anaconda的prompt,直接输入

  1. pip install theano

好像就装好了诶
但是这个时候在prompt内输入

  1. ipython

进入python界面,输入

  1. import theano

会收到warning,显示机器没有安装gcc,这意味着theano可以正常运行,但是效率堪忧
本着缺啥补啥的精神,楼主决定装一下g++和gcc

安装MinGW

度娘了一下,普遍认为使用MinGW为系统安装GCC是个不错的选择,但是安装过程中是在捉急。因为它是在线安装,在界面内进一步安装gcc和g++的时候····没。。有。。进。。度。。条!!!
装完以后要添加环境变量,这个过程很平凡,按照教程来就好.

测试

同样是进入ipython,然后import,这个时候你会发现····出错了,跑都跑不起来
度娘之发现可能是因为环境更新之后pyc文件没有更新,所以把theano中的.pyc文件全卸了,再来一次,果然有用——错误提示不一样了。
所以,楼主第一天就把mingw卸了,心里想着这样好歹还能将就着用。


第二战

看了这个帖子以后 http://blog.5ibc.net/p/10970.html
私以为这篇帖子说得对
所以在anaconda的prompt里面输入

  1. pip uninstall numpy
  2. pip uninstall scipy

等着待会全部重装

安装MinGW-W64

这个时候找到了一个64版本的mingw,喜出望外,果断下载之
下载完以后双击,选择X86_64,thread选项选择posix(支持C++11).
装完以后不同于上文链接中的安装方式了,进入MinGW\bin,我们会发现里面已经有了gcc和g++,所以直接从第六步开始,添加三个环境变量,并完成后续步骤。

  1. gcc -v
  1. gcc -o hello1.exe hello1.c
  1. #include <stdio.h>
  2. int main( int argc, char *argv[] )
  3. {
  4. printf( "Hello World!\n" );
  5. return 0;
  6. }
  1. g++ -o hello2.exe hello2.cpp
  1. #include <iostream>
  2. using namespace std;
  3. int main( int argc, char *argv[] )
  4. {
  5. cout << "Hello World!" << endl;
  6. return 0;
  7. }

未出错,则说明安装成功

安装BLAS和LAPACK

这一部分参考自教程但是在实际操作的时候还是有些细节感觉说得不清楚,所以决定写得再详细些。

安装LAPACK和BLAS

  1. C:\"Program Files"\mingw-w64\x86_64-6.1.0-posix-seh-rt_v5-rev0\mingw64\bin\mingw32-make.exe
  2. //引号用来防止cmd将C:\Program当做一个命令
  1. C:\"Program Files"\mingw-w64\x86_64-6.1.0-posix-seh-rt_v5-rev0\mingw64\bin\mingw32-make.exe test
  1. 100% tests passed, 0 tests failed out of 102
  1. program test_sgesv
  2. implicit none
  3. real :: a(3,3),b(3)
  4. integer :: v(3),iflag
  5. external sgesv
  6. a=reshape([2.0,0.0,0.0,0.0,3.0,0.0,0.0,0.0,4.0],[3,3])
  7. b=[998.0,999.0,1000.0]
  8. print *,'a=',a
  9. print *,'b=',b
  10. call sgesv(3,1,a,3,v,b,3,iflag)
  11. print *,'solve=',b
  12. end program test_sgesv

输出结果为

  1. a= 2.00000000 0.00000000 0.00000000 0.00000000 3.00000000 0.00000000 0.00000000 0.00000000 4.00000000
  2. b= 998.000000 999.000000 1000.00000
  3. solve= 499.000000 333.000000 250.000000

说明安装LAPACK和BLAS成功

安装Numpy和Scipy以

如前文所见,numpy和scipy已经被卸载了,所以,首先在anaconda prompt中输入

  1. conda install numpy
  2. conda update numpy
  3. pip install numpy

然后进入ipython输入

  1. import numpy
  2. numpy.test()

进行测试,显示

  1. Ran 6054 tests in 150.778s
  2. OK (KNOWNFAIL=8, SKIP=9)
  3. Out[3]:<nose.result.TextTestResult run=6054 errors=2 failures=0>

error可能是代码内部的一些一场,没有failure,numpy应该是安装成功了。接下来安装scipy

  1. conda install scipy
  2. conda update scipy
  3. pip install scipy

然后进入ipython输入

  1. import scipy
  2. scipy.test()

进行测试,显示

  1. Ran 20192 tests in 407.232s
  2. OK (KNOWNFAIL=100, SKIP=1628)
  3. Out[4]: <nose.result.TextTestResult run=20192 errors=0 failures=0>

所以scipy应该是安装成功了。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注