From 661cc0f59b31da14c89eafb2fde5c96fcfbde386 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Fri, 11 Aug 2023 13:24:50 +0100 Subject: [PATCH] Add multiprocess warning to README example --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 39a8d79..a3438bd 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,8 @@ distribution and Jacobian of constraint function), sample four chains in parallel using `multiprocess`, use `arviz` to calculate diagnostics and use `matplotlib` to plot the samples. +> ⚠️ **If you do not have [`multiprocess`](https://github.com/uqfoundation/multiprocess) installed the example code below will hang or raise an error when sampling the chains as the inbuilt `multiprocessing` module does not support pickling Autograd functions.** + ```Python from mici import systems, integrators, samplers import autograd.numpy as np @@ -317,8 +319,12 @@ def trace_func(state): # Sample 4 chains in parallel with 500 adaptive warm up iterations in which the # integrator step size is tuned, followed by 2000 non-adaptive iterations final_states, traces, stats = sampler.sample_chains( - n_warm_up_iter=500, n_main_iter=2000, init_states=q_init, n_process=4, - trace_funcs=[trace_func]) + n_warm_up_iter=500, + n_main_iter=2000, + init_states=q_init, + n_process=4, + trace_funcs=[trace_func] +) # Print average accept probability and number of integrator steps per chain for c in range(n_chain):