Some useful tips to accelerate your theano program

this blog may be updated at any time..


1) use some useful config in your .theanorc file, below is my configuration

---------------

[global]

floatX=float32

device=gpu2


[lib]

cnmem=0.9


[nvcc]

fastmath=True

----------------

it needs to mention that the cnmem is the pre-defined memory allocation for your program, if not set, your program would allocate gpu memory dynamically. If set to 1(whole usage) or 0.95~1 , a large gpu memory will be occupied for your program


2) Use matrix opperation..for example

 target_probability = T.diag(prediction_word_probability.T[target_word])

    is faster than

 target_probability = prediction_word_probability[T.arange(prediction_word_probability.shape[0]), target_word]


3) do not use dimshuffle  cast or alloc function, especilly inner scan


留下您的评论

回复列表:

By王炳宁 on Jan. 12, 2017 | 类别 Python

关于本站