def test_no_blas_crash_or_freeze_with_multiprocessing(): if sys.version_info < (3, 4): raise nose.SkipTest('multiprocessing can cause BLAS freeze on' ' old Python') # Check that on recent Python version, the forkserver start method can make # it possible to use multiprocessing in conjunction of any BLAS # implementation that happens to be used by numpy with causing a freeze or # a crash rng = np.random.RandomState(42) # call BLAS DGEMM to force the initialization of the internal thread-pool # in the main process a = rng.randn(1000, 1000) np.dot(a, a.T) # check that the internal BLAS thread-pool is not in an inconsistent state # in the worker processes managed by multiprocessing Parallel(n_jobs=2, backend='multiprocessing')(delayed(np.dot)(a, a.T) for i in range(2))
def test_no_blas_crash_or_freeze_with_multiprocessing(): if sys.version_info < (3, 4): raise nose.SkipTest('multiprocessing can cause BLAS freeze on' ' old Python') # Check that on recent Python version, the forkserver start method can make # it possible to use multiprocessing in conjunction of any BLAS # implementation that happens to be used by numpy with causing a freeze or # a crash rng = np.random.RandomState(42) # call BLAS DGEMM to force the initialization of the internal thread-pool # in the main process a = rng.randn(1000, 1000) np.dot(a, a.T) # check that the internal BLAS thread-pool is not in an inconsistent state # in the worker processes managed by multiprocessing Parallel(n_jobs=2, backend='multiprocessing')( delayed(np.dot)(a, a.T) for i in range(2))
def test_no_blas_crash_or_freeze_with_subprocesses(backend): if backend == 'multiprocessing': if sys.version_info < (3, 4): raise SkipTest('multiprocessing can cause BLAS freeze on old ' 'Python that relies on fork.') # Use the spawn backend that is both robust and available on all # platforms backend = mp.get_context('spawn') # Check that on recent Python version, the 'spawn' start method can make # it possible to use multiprocessing in conjunction of any BLAS # implementation that happens to be used by numpy with causing a freeze or # a crash rng = np.random.RandomState(42) # call BLAS DGEMM to force the initialization of the internal thread-pool # in the main process a = rng.randn(1000, 1000) np.dot(a, a.T) # check that the internal BLAS thread-pool is not in an inconsistent state # in the worker processes managed by multiprocessing Parallel(n_jobs=2, backend=backend)(delayed(np.dot)(a, a.T) for i in range(2))