How configure theano on Windows?
Asked Answered
E

3

5

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

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

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'

output:

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

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

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.

Egmont answered 18/1, 2015 at 15:44 Comment(1)
Possible duplicate of How do I install theano in Anaconda ver. 2.1 Windows 64 bit for Python 3.4?Touchhole
F
6

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

Sauce: http://ankivil.com/making-theano-faster-with-cudnn-and-cnmem-on-windows-10/

Finzer answered 13/6, 2017 at 10:19 Comment(1)
Thanks for the solution... U saved me :)Warmblooded
V
4

You are right that Theano does not need PyCUDA.

It is strange that Theano does not read your configuration file. The exact path that gets read is this. Just run this in Python and you'll see where to put it:

os.path.expanduser('~/.theanorc.txt')

Vestry answered 21/1, 2015 at 23:15 Comment(2)
the output of the above command is 'C:\\Users\\niko/.theanorc.txt'Egmont
Which version of Theano do you use? You should use the development version and not the last release: deeplearning.net/software/theano/…Vestry
B
2

Try to change the content in .theanorc.txt as indicating by Theano website ( http://deeplearning.net/software/theano/install_windows.html). The path needs to be changed accordingly based on your installation.

[global]
floatX = float32
device = gpu

[nvcc]
flags=-LC:\Users\cchan\Anaconda3\libs
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin
Boehm answered 28/2, 2017 at 23:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.