Skip to content

How do you setup NUM_THREADS env variables? #179

Closed

Description

@louisabraham

Following this discussion, I would like to make the dask tasks use only one thread each, even if they use BLAS / OMP.

I'm not sure here is the best place to ask, but how can we achieve that on a cluster?

I suppose we could modify the command line of the job scheduler to be able to export some variables.

Without dask, I have seen some other solutions with pure python code that modify os.environ before importing numpy, but I'm not sure how dask handles the imports.

Activity

  1. willirath commented on Oct 20, 2018

    @willirath
    Collaborator
  2. louisabraham commented on Oct 20, 2018

    @louisabraham
    ContributorAuthor

    Oh, very nice! Sorry, I should have looked better in the documentation.

    Maybe we could provide a nice argument that sets all those variables to the same value?
    Personally I have to google them again every time I need them, so this would be appreciable.

  3. willirath commented on Oct 20, 2018

    @willirath
    Collaborator
  4. guillaumeeb commented on Oct 20, 2018

    @guillaumeeb
    Member

    Maybe we could provide a nice argument that sets all those variables to the same value

    I prefer to avoid proposing too many functionalities in the codebase, especially if they would be used only by a handful of people.

    You can use env_extra as proposed by @willirath, and store your defaults in a configuration file.

    We could also add some documentation for this, explaining why it can be needed, and how to configure it.

  5. louisabraham commented on Oct 20, 2018

    @louisabraham
    ContributorAuthor

    I'm not sure this is a very frequent user case. Just out of curiosity: When and why do you need to restrict each task to one thread?

    I want to know exactly the CPU usage of my workers.
    If I "promise" to the job scheduler that I will use n cores (1 per task) but the BLAS/OMP routines use more, I'll definitely disrupt the other users, and some aggressive job schedulers might kill your workers.

    I prefer to avoid proposing too many functionalities in the codebase, especially if they would be used only by a handful of people.

    As I formulated it, it wasn't really useful and can be done without this functionality.

    What I need is a way to allocate cores*task_threads cores and set *_NUM_THREADS=task_threads.

    So if one wants task_threads=1 then env_extra is enough, but otherwise it is necessary to be able to allocate more cores.

    In my use case, task_threads=1 is perfect so I won't take offence if you decide no one needs that.

  6. guillaumeeb commented on Oct 20, 2018

    @guillaumeeb
    Member

    So if one wants task_threads=1 then env_extra is enough, but otherwise it is necessary to be able to allocate more cores.

    If you need to do something like this, then use ncpus to tell LSF you will need more resources than just the one used by the workers:

    cluster = LSFCluster(cores=4, ncpus=16, env_extra=['OMP_NUM_THREAD=4'])

    Does that sound OK for your need?

  7. louisabraham commented on Oct 23, 2018

    @louisabraham
    ContributorAuthor

    I don't know on what issue I should answer (maybe we should close one or both to create a new one that summarizes the two).

    As pointed by the code on the other issue, the interface is different between schedulers. It would be good to unify the apis for the number of cores.

    You would be right to argue that this problem is not frequent enough to change the api, but having a consistent api will allow to better explain the threads, processes, etc....

  8. guillaumeeb commented on Oct 23, 2018

    @guillaumeeb
    Member

    As pointed by the code on the other issue, the interface is different between schedulers. It would be good to unify the apis for the number of cores.

    Yes I think your totally right about this. So I will not try to argue as there is two of you needing this (is this a friend of you 🙂 ?). As this issue was first on ENV var, and I think we've answer that part. I propose to close this issue in favor of #181 which is focused on the second problem you mention. Happy to leave it open though if you think you need to clarify things in the docs or anywhere in the code.

  9. louisabraham commented on Oct 24, 2018

    @louisabraham
    ContributorAuthor

    I swear we don't know each other!

    Agreed to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions