我在Windows机器上安装了Theano并按照配置说明进行操作.
我将以下.theanorc.txt文件放在C:\ Users\my_username文件夹中:
#!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
Run Code Online (Sandbox Code Playgroud)
我试图运行测试,但还没有设法在GPU上运行它.我猜不会读取.theanorc.txt中的值,因为我添加了行print config.device并输出"cpu".
下面是基本的测试脚本和输出:
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'
Run Code Online (Sandbox Code Playgroud)
输出:
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
Run Code Online (Sandbox Code Playgroud)
我已成功安装CUDA Toolkit但尚未设法安装pyCUDA.我猜Theano应该在没有安装pyCUDA的情况下工作.
如果有人能帮助解决这个问题,我将非常感激.我已按照这些说明操作,但不知道为什么程序中的配置值与.theanorc.txt文件中的值不匹配.
与在几页上所说的相反,我的安装(Windows 10,Python 2.7,Theano 0.10.0.dev1)不会解释.theanorc.txt用户配置文件文件夹中文件中的配置指令 ,而是会读取.theanorc文件。
如果您在创建具有这种名称样式的文件时遇到问题,请在终端上使用以下命令:
cd %USERPROFILE%
type NUL > .theanorc
Run Code Online (Sandbox Code Playgroud)
调味料:http : //ankivil.com/making-theano-faster-with-cudnn-and-cnmem-on-windows-10/
你是对的,Theano 不需要 PyCUDA。
奇怪的是 Theano 没有读取你的配置文件。读取的确切路径是这样的。只需在 Python 中运行它,您就会看到将其放在哪里:
os.path.expanduser('~/.theanorc.txt')
| 归档时间: |
|
| 查看次数: |
12651 次 |
| 最近记录: |