Defining multiple models with pm.Model() shuts down kernel?

Hey all, i have been trying to do GP regression for multiple data sets using

with pm.Model() as model:
ℓ = pm.Uniform('ℓ', lower=np.sqrt(5.0), upper=6.0*50.0*np.sqrt(2.0)) 
η = pm.Uniform('η', lower=0.0, upper=1.0)

cov = η**2 *, ℓ)
gp =

σ = pm.HalfNormal("σ", sigma=np.sqrt(np.pi/(np.pi-2)))#pm.HalfCauchy("σ", beta=0.5)

y_ = gp.marginal_likelihood("y", X=X, y=y, noise=σ)

trace = pm.sample(2000) 

but i run into problems if i do multiple models in one script. Say i define one model as

with pm.Model() as model1:

and another model as

with pm.Model() as model2:

If i run the first one there is no problem, but when i run the second one it starts to sample but gets stuck, the kernel then disconnects and cannot reconnect and i have to close down anaconda to get it working again. If i run it the other way around i get the same result, model2 runs fine but model1 crashes. The models themselves are identical other than the input data they receive.

Does this have something to do with how i define the models? Or is this a limitation in pymc3?

Looks like it is out of memory - it easily happens with Gaussian Process.

Okay so i would need some way to either save my results or clear the memory before running the other model. I would prefer to do the latter since i have to run many of these models. Is there a way to clear the result from a GP so it does not take up memory?