Number of workers in simulated training

This question was migrated from Github Discussions.

Original questions:
Hi everyone i am using fl.simulation. Maybe my question is naive, but i was wondering if there is a way to choose the number of worker when i execute start_simulation? becuase i notice wheni run it it spawn only 2 worker. Another question on the simulation it is possible to enabkle the gpu accelerator?

Answer 1:
Pass num_clients=n to start_simulation() where ‘n’ is the number of workers you want. Then you can also tweak various parameters in the strategy to configure the clients sampling in each round.

Answer 2:
The number of workers one will see depends on several factors. Two important ones are:

  • num_clients (as mentioned in Answer 1)
  • fraction_fit (in the strategy) - if you, for example, call start_simulation with num_clients=100 and a strategy that has fraction_fit set to 0.5 then you should see more workers being created

You could try to reproduce this with the first part of the Flower tutorial: Flower Intro to FL - Pythorch