If you want to be able to change the devices, you can't pickle the Theano
graph. You must saves the weights themself, rebuild the model and set the
weights in the shared variables again.

Do you use a framework on top of Theano? If so, they normally have doc
about how to do that.

The old back-end and the new back-end should act the same about that.

One problem that I see is that you should use theano.tensor.nnet.conv2d
(not theano.tensor.nnet.conv.conv2d) with the new back-end. With the old
back-end, this should give you faster code in many cases.

To be sure you update your code correctly for the new back-end, be sure to
follow the instruction there:
https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

Fred

On Fri, Apr 7, 2017 at 11:24 AM Shariq Iqbal <[email protected]>
wrote:

> Hello,
>
> I have a time series model that requires two portions of training: one
> which is run on a CPU (it can only look at one trial per iteration, so the
> data transfer cost to CPU is not worth it), and one which is run on a GPU
> (this portion considers time points independently, and, thus, can be
> parallelized). Training the CPU portion and then loading the pickled model
> for GPU training works fine, but when we train the GPU portion and try to
> load it with the CPU backend, we receive this error:
>
> ContextNotDefined: (ContextNotDefined('context name None not defined',), <
> function GpuArray_unpickler at 0x7fd58f7468c0>, (array(...array_values...,
> dtype=float32), None))
>
> When we load the trained model on a GPU, it loads properly, but when we
> try to run it, we receive an error about ConvOp not working with gpuarray
> backend since the CPU portion of the model uses
> theano.tensor.signal.conv.conv2d, rather than
> theano.tensor.nnet.conv.conv2d.  This is not a huge problem, as we can
> change the convolution that we are using; however, we are hoping to be able
> to run the trained model end-to-end on a CPU, so I was wondering if there
> is any workaround to get gpuarrays to load on CPU. This was all working
> prior to our upgrading to the gpuarray backend, but we would like to be
> future-proof.
>
> Thanks!
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "theano-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to