在window10下安装theano GPU版本+keras1.2
2017-07-28 00:00
225 查看
因为业务需要,需要安装一个theanoGPU版本+keras1.2环境来运行代码。经过百度搜索和多次实验,终于成功地完成安装和测试。
1、首先要安装好Anaconda。
接下来创建一个虚拟环境keras12
2、condacreate–nkeras12python=2.7
3、激活keras12虚拟环境
activatekeras12
4、使用conda命令安装theanogpu版本
condainstalltheanopygpu
5、下载keras1.22版本并安装
https://github.com/fchollet/keras/releases
下载1.2.2版本
解压到硬盘的某个目录下,使用pythonsetup.pyinstall
安装Keras1.22版本
6、把keras默认后台配置修改成theano
在C:\Users\Administrator\.keras目录下
修改keras.json。把里面的tensorflow相关的信息换成theano的。
{
"floatx":"float32",
"backend":"theano",
"epsilon":1e-07,
"image_dim_ordering":"th"
}
修改C:\Users\Administrator\.theanorc.txt。把device选项设置成gpu
[global]
device=gpu
#device=cpu
floatX=float32
openmp=False
allow_input_downcast=True
#optimizer_including=cudnn
[blas]
ldflags=
[gcc]
remcxxflags=-IE:\common\mingw-w64\i686\mingw32\i686-w64-mingw32\include
[nvcc]
fastmath=True
flags=-LE:\Anaconda2\envs\keras1\libs
compiler_bindir=F:/ProgramFiles(x86)/MicrosoftVisualStudio13/VC/bin/x86_amd64
[lib]
cnmem=0.8
如何配置CUDNN:
https://stackoverflow.com/questions/36248056/how-to-setup-cudnn-with-theano-on-windows-7-64-bit/36464973
7、测试。
进入python环境,importkeras
如果一切正常,那就安装好了。我自己跑了一个使用GPU加速的程序:
fromtheanoimportfunction,config,shared,tensor
importnumpy
importtime
vlen=10*30*768#10x#coresx#threadspercore
iters=1000
rng=numpy.random.RandomState(22)
x=shared(numpy.asarray(rng.rand(vlen),config.floatX))
f=function([],tensor.exp(x))
print(f.maker.fgraph.toposort())
t0=time.time()
foriinrange(iters):
r=f()
t1=time.time()
print("Looping%dtimestook%fseconds"%(iters,t1-t0))
print("Resultis%s"%(r,))
ifnumpy.any([isinstance(x.op,tensor.Elemwise)and
('Gpu'notintype(x.op).__name__)
forxinf.maker.fgraph.toposort()]):
print('Usedthecpu')
else:
print('Usedthegpu')
只用CPU,程序要跑12秒多。使用GPU加速,只需要0.25秒。还行。
1、首先要安装好Anaconda。
接下来创建一个虚拟环境keras12
2、condacreate–nkeras12python=2.7
3、激活keras12虚拟环境
activatekeras12
5、下载keras1.22版本并安装
下载1.2.2版本
解压到硬盘的某个目录下,使用pythonsetup.pyinstall
安装Keras1.22版本
6、把keras默认后台配置修改成theano
在C:\Users\Administrator\.keras目录下
修改keras.json。把里面的tensorflow相关的信息换成theano的。
{
"floatx":"float32",
"backend":"theano",
"epsilon":1e-07,
"image_dim_ordering":"th"
}
修改C:\Users\Administrator\.theanorc.txt。把device选项设置成gpu
[global]
device=gpu
#device=cpu
floatX=float32
openmp=False
allow_input_downcast=True
#optimizer_including=cudnn
[blas]
ldflags=
[gcc]
remcxxflags=-IE:\common\mingw-w64\i686\mingw32\i686-w64-mingw32\include
[nvcc]
fastmath=True
flags=-LE:\Anaconda2\envs\keras1\libs
compiler_bindir=F:/ProgramFiles(x86)/MicrosoftVisualStudio13/VC/bin/x86_amd64
[lib]
cnmem=0.8
如何配置CUDNN:
7、测试。
进入python环境,importkeras
如果一切正常,那就安装好了。我自己跑了一个使用GPU加速的程序:
importnumpy
importtime
vlen=10*30*768#10x#coresx#threadspercore
iters=1000
rng=numpy.random.RandomState(22)
x=shared(numpy.asarray(rng.rand(vlen),config.floatX))
f=function([],tensor.exp(x))
print(f.maker.fgraph.toposort())
t0=time.time()
foriinrange(iters):
r=f()
t1=time.time()
print("Looping%dtimestook%fseconds"%(iters,t1-t0))
print("Resultis%s"%(r,))
ifnumpy.any([isinstance(x.op,tensor.Elemwise)and
('Gpu'notintype(x.op).__name__)
forxinf.maker.fgraph.toposort()]):
print('Usedthecpu')
else:
print('Usedthegpu')
只用CPU,程序要跑12秒多。使用GPU加速,只需要0.25秒。还行。
相关文章推荐
- Ubuntu17.04安装TensorFlow1.2的GPU版本
- 在ubuntu或者min运行环境下安装gpu版本的tensorflow
- Python 虚拟环境+安装MxNet(CPU和GPU版本)
- Ubuntu 14.04 64bit 安装Caffe(GPU版本)
- ubuntu16.04下使用anaconda安装tensorflow_gpu版本以及object detection的过程
- windows 10 安装CUDA 7.5和PyCUDA(在GPU上运行theano)
- Win10 64bit 安装Theano 配置CUDA 实现GPU加速 详细步骤
- TensorFlow GPU版本安装(3):Anoconda版本安装
- linux 安装tensorflow(gpu版本)
- win10下基于python(anaconda)安装gpu版本的TensorFlow以及kears深度学习框架
- window7 安装GPU版本TensorFlow遇到一些列的坑
- 在win10下安装配置tensorflow_gpu版本(简单)
- 非Anaconda纯PYTHON环境下Theano基于WIN10的纯净CUDA安装与GPU配置
- Ubuntu 16.06 Tensorflow 1.4 GPU版本傻瓜安装教程
- 亲测:在Ubuntu16.04上成功安装GPU版本的tensorflow
- Windows 7/8.1 下 双版本Python2.7/Python3.5 安装 GPU版的tensorflow
- Ubuntu16.04安装配置GPU版本Caffe经验总结
- Win10 安装Tensorflow-GPU版本
- Windows下VS2015编译caffe(无GPU版本),安装简单