I would like to execute afni commands from python, e.g., using subprocess.check_call() or ipython’s ! notation.
However, it seems that commands with OpenMP multithread support, e.g., 3dREMLfit or 3dDeconvolve, only deploy a single thread when executed from python, dramatically slowing down the computation.
For example, when I run
subprocess.check_call([‘tcsh’, ‘stats.REML_cmd’])
or
!tcsh stats.REML_cmd
in ipython, it spawns only one thread and computes very slowly. But when I run the same script directly from the shell
$ tcsh stats.REML_cmd
it spawns 15 thread and runs considerably faster.
Is there a way to execute 3dREMLfit in multithreaded mode from python?
% system_profiler SPSoftwareDataType
System Version: macOS 10.12 (16A323)
Kernel Version: Darwin 16.0.0
Boot Volume: C
Boot Mode: Normal
Secure Virtual Memory: Enabled
System Integrity Protection: Disabled
Time since boot: 6 days 8:11
Previously, I tested both subprocess and ! notation in jupyter notebook, and got the single threaded result.
I’ve just re-tested them in vanilla ipython console, and as rick said, both of them worked as expected with OpenMP enabled.
Reinstalled anaconda (Python 3.5.2 |Anaconda 4.2.0 (x86_64)), now OpenMP works in jupyter notebook.
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.