本文介绍了如何在Windows上配置theano?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows计算机上安装了Theano,并遵循了说明的配置.

I have Installed Theano on Windows machine and followed the configuration instructions.

我将以下.theanorc.txt文件放置在C:\ Users \ my_username文件夹中:

I placed the following .theanorc.txt file in C:\Users\my_username folder:

#!sh
[global]
device = gpu
floatX = float32

[nvcc]
fastmath = True
# flags=-m32 # we have this hard coded for now

[blas]
ldflags =
# ldflags = -lopenblas # placeholder for openblas support

我试图运行测试,但是没有设法在GPU上运行它.我猜未读取.theanorc.txt中的值,因为我添加了行print config.device并输出"cpu".

I tried to run the test, but haven't managed to run it on GPU. I guess the values from .theanorc.txt are not read, because I added the line print config.device and it outputs "cpu".

下面是基本的测试脚本和输出:

Below is the basic test script and the output:

from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

print config.device


vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print f.maker.fgraph.toposort()
t0 = time.time()
for i in xrange(iters):
    r = f()
t1 = time.time()
print 'Looping %d times took' % iters, t1 - t0, 'seconds'
print 'Result is', r
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print 'Used the cpu'
else:
    print 'Used the gpu'

输出:

pydev debugger: starting (pid: 9564)
cpu
[Elemwise{exp,no_inplace}(<TensorType(float64, vector)>)]
Looping 1000 times took 10.0310001373 seconds
Result is [ 1.23178032  1.61879341  1.52278065 ...,  2.20771815  2.29967753
  1.62323285]
Used the cpu

我已经成功安装了CUDA Toolkit,但是没有成功安装pyCUDA.我想Theano应该在没有安装pyCUDA的情况下也可以工作.

I have installed CUDA Toolkit successfully but haven't managed to install pyCUDA. I guess Theano should work without pyCUDA installed anyway.

如果有人可以帮助解决这个问题,我将非常感激.我已按照这些说明进行操作,但不知道为什么程序中的配置值与.theanorc.txt文件中的值不匹配.

I would be very thankful if anyone could help out solving this problem. I have followed these instructions but don't know why the configuration values in the program don't match the values in .theanorc.txt file.

推荐答案

与在几页上所说的相反,我的安装(Windows 10,Python 2.7,Theano 0.10.0.dev1)不会解释配置指令在我的用户个人资料文件夹中的.theanorc.txt文件中,但会读取.theanorc文件.

Contrary to what has been said on a couple of pages, my installation (Windows 10, Python 2.7, Theano 0.10.0.dev1) would not interpret config instructions within a .theanorc.txt file in my user profile folder, but would read a .theanorc file.

如果在创建具有这种名称样式的文件时遇到问题,请在终端上使用以下命令:

If you are having trouble creating a file with that style of name, use the following commands at a terminal:

cd %USERPROFILE%
type NUL > .theanorc

调味料: http://ankivil .com/make-theano-faster-with-cudnn-and-cnmem-on-windows-10/

这篇关于如何在Windows上配置theano?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-13 09:34