Hi,
Multi-GPU with multi-thread/process isn't trivial. You must take care in
the order in which context get instanciated.
I don't recall how it must be done for multiple threads. For
multiple-process, you must fork the process before initializing the context.
Theano function aren't thread safe.
Hmm ... my bad. I thought givens would work.
Anyway, this trick would work:
import theano
from theano.gpuarray.basic_ops import infer_context_name
gpu_fmatrix = theano.gpuarray.GpuArrayType(dtype='float32', broadcastable=(
False,False))
a_gpu = T.fmatrix()
# insert transfer
a =
That does not seem to work. So I have this:
a = T.fmatrix()
ctx = pygpu.init(theano.config.device)
theano.gpuarray.reg_context("mine", ctx)
a_gpu = theano.gpuarray.GpuArrayType(a.dtype, a.broadcastable, "mine")
f2 = theano.function([a_gpu], a + T.constant(2), givens={a: a_gpu})
return f1, f2
In the main graph, replace the input variables with type:
theano.gpuarray.GpuArrayType (Can be done using givens parameter of
theano.function). Then, feed pygpu.gpuarray.GpuArray object directly to the
compiled function. pygpu.gpuarray.asarray can be used to move numpy array
to GPU.
On