How to run more than 2 parallel process

Hello Community!! I’m very new to Ray and I tried the basic example available on Github, on Google Colab and its GPU. I edited the code a bit to notice its working. Here the code:

import ray
import time
def f(x):
    print(f"With Process {x}")
    return x * x

futures = [f.remote(i) for i in range(4)]

I noticed that at one particular time, only two parallel processes were running and others were waiting for them to finish.

I’m trying to run more than 2 parallel process.

Can anyone please give me a clue how to do it? Thanks in advance!!

Hi @xanthan,

What does your dev environment look like? It is possible that you don’t have enough physical cores on your machine.

Try, setting it to 4 by using ray.init(num_cpus=4) (more info here)

Or, try reducing the cpu requirements for the task by using @ray.remote(num_cpus=0.5) - by default each task requires 1 cpu. More info here.

Hope this helps!

hello @samrogers226 ,

I’m running the code on Google Colab.

I’m trying to run it on a GPU on Colab. But I still tried your code with num_gpus instead of num_cpus but it doesn’t seem to work

@xanthan I believe we addressed this together in the slack channel. Would you mind sharing the conclusion?