2

I am able to find out the worker address. But I want to know the name. Is there any method to find out?

from dask.distributed import Client, LocalCluster
cluster = LocalCluster(name='AAA',n_workers=1,threads_per_worker=2)
client = Client(cluster)
client
Professor
  • 87
  • 6

1 Answers1

3

To get the name, you can do

from distributed import get_worker
client.run(lambda: get_worker().name)

However, this will not be the name you gave, but a numerical index 0, 1.... ; you seem to be trying to give the same name across a whole cluster (even with just one worker), so that doesn't work. You could do it if you were starting the worker process yourself on the command line or programatically.

There is also an alternative .id attribute, which is a unique UUID-based string for each worker.

mdurant
  • 27,272
  • 5
  • 45
  • 74
  • It is working. Is there any way to change the worker's name? I want to change the name because of the following reason: - I want to assign 2 different ML models to two different workers. - And When adding more workers using the scale-up method. I am not sure, which is the new worker. By assigning a new name. I can keep track of that. – Professor Jul 13 '22 at 05:10
  • 1
    Not with the LocalCluster, no – mdurant Jul 13 '22 at 13:43
  • Is it possible if the dask is running on kubernet cluster (remote server) ? – Professor Jul 13 '22 at 18:02
  • Is it possible to get the worker ID or process ID in numbers within a node? I need this information to determine the GPU placement: process 0 sees GPU#0,1; process 1 sees GPU#2,3; process 2 sees GPU#4,5; process 3 sess GPU#6,7. – llodds Oct 27 '22 at 15:45
  • Process ID from `os.getpid()`? – mdurant Oct 27 '22 at 18:08