gpt4 book ai didi

python - 如何在 Windows 上配置 theano?

转载 作者:太空狗 更新时间:2023-10-30 00:31:55 25 4
gpt4 key购买 nike

我已经在 Windows 机器上安装了 Theano 并遵循配置 instructions .

我将以下 .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

我尝试运行测试,但未能在 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'

输出:

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 工具包,但还没有成功安装 pyCUDA。我想 Theano 应该可以在没有安装 pyCUDA 的情况下工作。

如果有人能帮助解决这个问题,我将不胜感激。我关注了these说明,但不知道为什么程序中的配置值与 .theanorc.txt 文件中的值不匹配。

最佳答案

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

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

cd %USERPROFILE%
type NUL > .theanorc

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

关于python - 如何在 Windows 上配置 theano?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28011551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com