簡體   English   中英

在GPU(Windows)上運行Theano的命令

[英]Command to run Theano on GPU (windows)

我在這里討論教程http://deeplearning.net/software/theano/tutorial/using_gpu.html

我使用的代碼

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

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 range(iters):
    r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (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')

使用GPU測試Theano部分:有一些命令行將Theano標志設置為在cpu或gpu上運行。 問題是我不知道把這些命令放進去。

我試過windows cmd

THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python theanogpu_example.py

然后我明白了

'THEANO_FLAGS' is not recognized as an internal or external command,
operable program or batch file.

T1

但是,我能夠使用該命令在cpu上運行代碼

python theanogpu_example.py

T2

我想在GPU上運行代碼,我該怎么做(在教程中使用這些命令)?


感謝@Blauelf關於windows環境變量的想法。 但是,這個參數必須分開

set THEANO_FLAGS="mode=FAST_RUN"  & set THEANO_FLAGS="device=gpu" & set THEANO_FLAGS="floatX=float32" & python theanogpu_example.py 

文檔中THEANO_FLAGS是一個環境變量。 因此,當您使用Windows時,您可能想要更改

THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python theanogpu_example.py

set THEANO_FLAGS="mode=FAST_RUN,device=gpu,floatX=float32" & python theanogpu_example.py

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM