I use some code like below for my task multiprocess processing.
import ray
import time
import psutil
import re
from math import ceil
import pdb
# Start Ray.
ray.init(num_cpus=4) # I would use 4 cpus
@ray.remote
def preprocessing_text(input_text):
new_text = str(input_text).lower()
# and some other text processing operation
return new_text
result_list = []
for i in range(50000):
result_list.append(preprocessing_text.remote("AbcDefG"))
results = ray.get(result_list)
When i use top
in terminal, it seems just single process work at the same time, and at different times maybe different process work. Why can not the 4 processes work at the same time? It seems that the parallel fail? Or is there something i misunderstand? Thanks a lot!