I am trying to use Ray Core for communication between nodes for multinode clusters. The problem is that, one Ray actor can only work on one core at a time, and the C++ APIs I’m calling from the python are using openmp for loop optimization. So, the loop optimization is becoming redundant. I need to use Ray Core such that I could use those loop optimization.
One more approach I am thinking of is to use Ray Actors just for communication between nodes and start another process which can run my program in background on that process where I can use openmp parallelization. But till now, not able to find any lead on that.
Could anyone suggest some solution/approaches for this problem?
hi @pratkpranav, thanks for your interest in Ray.
I’m not familiar with OpenMP, but you can start a background thread in the Actor constructor;
@ray.remote
class MyActor:
def __init__(self,):
self.thread = threading.Thread(target=self._run_in_thread, daemon=True)
self.thread.start()
def _run_in_thread(self):
# run stuff in a separate thread
Actually, the python environment variable ‘OMP_NUM_THREADS’ is set to 1 by default, and even after increasing the num_cpus to K>1, ‘OMP_NUM_THREADS’ remain to be 1. If we explicitly change the ‘OMP_NUM_THREADS’ variable with something like export OMP_NUM_THREADS=“10”, it works. That is, openmp runs behind the ray actor.
ah got it. you can set that env variable either through runtime env (Environment Dependencies — Ray 1.13.0), or set a system env variable.