Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importing tedana in python seems to lock my multiprocessing to one core #473

Closed
Aaronearlerichardson opened this issue Nov 20, 2019 · 3 comments · Fixed by #537
Closed
Labels
bug issues describing a bug or error found in the project priority: high issues that would be really helpful if they were fixed already

Comments

@Aaronearlerichardson
Copy link

Aaronearlerichardson commented Nov 20, 2019

Summary

I am writing a preprocessing script in python which mostly involves using nipype to wrap afni terminal commands. Normally afni will either automatically use all available cpus or take a manually given amount to process certain commands, however when I import tendana, nipype will only use one. Could this have to do with #188 ?

Additional Detail

Here is a sample code for a wrapper in my script:

import nipype
from multiprocessing import cpu_count
from nipype.interfaces import afni as afni
from tedana.workflows import t2smap_workflow

def warp(self,fileobj1,fileobj2,out_file,transformation=None,args=None,saved_mat_file=None):

        ThreeDWarp = afni.Warp(in_file=fileobj1,out_file=out_file)
        if args is not None:
            ThreeDWarp.inputs.args=args
        if transformation == 'card2oblique':
            ThreeDWarp.inputs.oblique_parent = fileobj2
        elif transformation == 'deoblique':
            ThreeDWarp.inputs.deoblique = True
        elif transformation == 'mni2tta':
            ThreeDWarp.inputs.mni2tta = True
        elif transformation == 'tta2mni':
            ThreeDWarp.inputs.tta2mni = True
        elif transformation == 'matrix':
            ThreeDWarp.inputs.matparent = fileobj2
        elif transformation == None:
            print("Warning: no transformation input given")
        else:
            print("Warning: none of the transformation options given match the possible arguments. Matching arguments are card2oblique,"+
             " deoblique, mni2tta, tta2mni, and matrix")
        ThreeDWarp.inputs.num_threads = cpu_count()

        if saved_mat_file: #this is for if the pipline requires saving the 1D matrix tranformation information
            print('saving matrix')
            ThreeDWarp.inputs.verbose = True
            ThreeDWarp.inputs.save_warp = True
            
        ThreeDWarp.run()

Next Steps

printing os.environ gives me ({ 'OMP_NUM_THREADS': '1', 'LESSOPEN': '| /usr/bin/lesspipe %s', '_': '/usr/bin/python3', 'MKL_NUM_THREADS': '1', 'NUMEXPR_NUM_THREADS': '1', 'VECLIB_MAXIMUM_THREADS': '1', 'KMP_DUPLICATE_LIB_OK': 'True', 'KMP_INIT_AT_FORK': 'FALSE'})

I changed OMP_NUM_THREADS and fixed my issue, but wanted to post this so that the devs here would know how this can affect nipype.

@tsalo
Copy link
Member

tsalo commented Nov 23, 2019

Hi @Aaronearlerichardson. Thanks for bringing this to our attention. This limitation was introduced in #215 because tedana was automatically using all cores, but that was always meant as a temporary fix. We definitely want to handle parallel processing more appropriately, and we definitely don't want there to be any downstream impacts on other steps in anyone's workflow.

We have an issue currently open (#401) that is a followup to #188, but it has been relatively low-priority until now. I've bumped up the priority for that issue, but I don't know when we'll be able to address it. @jbteves does have a plan for the problem, though, so he might be able to deal with it at some point, or if you want you could take a crack at it.

@tsalo tsalo added bug issues describing a bug or error found in the project priority: high issues that would be really helpful if they were fixed already labels Nov 23, 2019
@stale
Copy link

stale bot commented Feb 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to tedana:tada: !

@tsalo
Copy link
Member

tsalo commented Feb 21, 2020

Not stale. Hopefully #537 will solve this. 🤞

@stale stale bot removed the stale label Feb 21, 2020
@tsalo tsalo mentioned this issue Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues describing a bug or error found in the project priority: high issues that would be really helpful if they were fixed already
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants