question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set GPU ThreadPoolExecutor and set known libraries to use it

See original GitHub issue

With @madsbk 's recent work allowing for multiple executors, we might consider making a GPU ThreadPoolExecutor in workers by default if a GPU is detected, and then annotating tasks known to be GPU-targetted with that annotation. This would improve the likelihood that a user of vanilla dask has a good time with RAPIDS, cupy, or other known project.

We probably can’t do this in full generality (it’s hard to detect what code has GPUs) but we’re no worse off if we don’t catch something, and we can handle the common cases well.

Concretely, I propose:

  1. Having the Worker class try importing pynvml (or some future NVIDIA python library) and if it detects a GPU then create a single-threaded ThreadPoolExecutor

    try:
        import pynvml
    except ImportError:
        pass
    else:
        if pynvml.do_I_have_a_gpu():
            self.executors["gpu"] = ThreadPoolExecutor
    
  2. In known GPU libraries we would add an annotation to every layer

    class ArrayLayer:
        def __init__(self, ...):
            if "cupy" in str(type(self._meta)):
                self.annotations["executor"] = "gpu" # or use setdefault or something
    

cc @madsbk @quasiben @kkraus14

dask-cuda handles this for users who use it. This feels like something that we could upstream. This would also help with CPU-GPU mixed computation.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
mrocklincommented, Jul 26, 2021

I think that there are good ideas behind all of those things, and like the PR here does for threads and executors, we would need to find nice generic ways to incorporate them.

0reactions
rjzamoracommented, Jul 29, 2021

would you all consider adding an executor=“gpu” annotation to RAPIDS layers?

Peter and Ben probably have the best idea of what the appropriate defaults should be, but this particular request seems reasonable to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use ThreadPoolExecutor in Python
ThreadPoolExecutor provides an interface that abstracts thread management from users and provides a simple API to use a pool of worker threads.
Read more >
concurrent.futures — Launching parallel tasks — Python 3.11 ...
When using ProcessPoolExecutor , this method chops iterables into a number of chunks which it submits to the pool as separate tasks. The...
Read more >
How to use queue with concurrent future ThreadPoolExecutor ...
Can some put me a example of using a queue with concurrent library? I am getting TypeError: 'Queue' object is not iterable I...
Read more >
Advanced multi-tasking in Python: Applying and ...
We can easily create pools for both threads and processes with the concurrent library. In the part below we'll get into the code....
Read more >
Asynchronous work with Java threads - Android Developers
This guide shows how developers using the Java Programming Language can use a thread pool to set up and use multiple threads in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found