Message314528
@ronaldoussoren: The order of the imports made no difference. Even with the call at the top, I got endless errors with both 'spawn' and 'forkserver', with or without importing a graphics backend. Only 'fork' works, and only if a graphics package is not imported.
** HOWEVER **
Setting method='spawn' or 'forkserver' and force=True at top, or calling multiprocessing.set_start_method in __main__ does work (when run as scripts from command line). It's a shame to have to give up the convenience of 'fork', but this is a start.
```
import multiprocessing
multiprocessing.set_start_method("spawn", force=True)
import numpy as np
# import _tkinter
def parallel_matmul(x):
R = np.random.randn(3, 3)
return np.matmul(R, x)
if __name__ == '__main__':
# multiprocessing.set_start_method("spawn", force=False)
pool = multiprocessing.Pool(4)
results = pool.map(parallel_matmul, [np.random.randn(3, 5000) for i in range(2)])
``` |
|
Date |
User |
Action |
Args |
2018-03-27 14:53:47 | ezwelty | set | recipients:
+ ezwelty, terry.reedy, ronaldoussoren, ned.deily |
2018-03-27 14:53:47 | ezwelty | set | messageid: <1522162427.17.0.467229070634.issue33111@psf.upfronthosting.co.za> |
2018-03-27 14:53:47 | ezwelty | link | issue33111 messages |
2018-03-27 14:53:47 | ezwelty | create | |
|