flower
flower copied to clipboard
Flower server and client communication issue
What is your question?
Hi, I have set number of rounds for server end as 2. num_rounds=2. I started the server, then starts two clients.
Each client closed after one round,but server keep listening. The client side error msg is,
Exception: NumPyClient.fit did not return a tuple with 3 elements. The returned values should have the following type signature:
Tuple[List[np.ndarray], int, Dict[str, Scalar]]
Example
model.get_weights(), 10, {"accuracy": 0.95}
I restarted the clients after that. After 2 restarts, clients shows successfully completed the run, and server shows the results as follows,
> DEBUG flower 2022-06-06 01:06:07,874 | server.py:161 | evaluate_round: strategy sampled 2 clients (out of 2)
> DEBUG flower 2022-06-06 01:06:07,905 | server.py:174 | evaluate_round received 2 results and 0 failures
> DEBUG flower 2022-06-06 01:06:07,915 | server.py:207 | fit_round: strategy sampled 2 clients (out of 2)
> DEBUG flower 2022-06-06 01:06:07,945 | server.py:220 | fit_round received 0 results and 2 failures
> INFO flower 2022-06-06 01:06:07,945 | server.py:120 | fit progress: (5, 0.6931471805599453, {'accuracy': 0.6320346320346321}, 41.076001000000005)
> DEBUG flower 2022-06-06 01:06:13,713 | server.py:161 | evaluate_round: strategy sampled 2 clients (out of 2)
> DEBUG flower 2022-06-06 01:06:13,732 | server.py:174 | evaluate_round received 2 results and 0 failures
> INFO flower 2022-06-06 01:06:13,732 | server.py:138 | FL finished in 46.858959799999994
> INFO flower 2022-06-06 01:06:13,732 | app.py:178 | app_fit: losses_distributed [(1, 0.6931471824645996), (2, 0.6931471824645996), (3, 0.6931471824645996), (4, 0.6931471824645996), (5, 0.6931471824645996)]
> INFO flower 2022-06-06 01:06:13,732 | app.py:179 | app_fit: metrics_distributed {}
> INFO flower 2022-06-06 01:06:13,732 | app.py:180 | app_fit: losses_centralized [(0, 0.6931471805599453), (1, 0.6931471805599453), (2, 0.6931471805599453), (3, 0.6931471805599453), (4, 0.6931471805599453), (5, 0.6931471805599453)]
> INFO flower 2022-06-06 01:06:13,732 | app.py:181 | app_fit: metrics_centralized {'accuracy': [(0, 0.6320346320346321), (1, 0.6320346320346321), (2, 0.6320346320346321), (3, 0.6320346320346321), (4, 0.6320346320346321), (5, 0.6320346320346321)]}
>
Is the above flowerfl sklearn server and client process valid.
Pls sugegst why my client disconencted each round.
Thanks,
SJayaram
The server.py should be independent of the client.py - if the clients disconnect, the server will still be listening.
It is hard to say why the client is disconnecting without looking at your exact code. As far as the error message suggests, the problem occurs at the NumPyClient.fit stage - so perhaps something wrong is happening with the model fitting (for some reason, it does not return a tuple with a designated signature - either weights, int or accuracy metrics is missing. Further examination would require the source code.
HI, thank you. I modified the numpy_client.py inside flwr->client as ,
- commented at Line: 196 ``` # if not ( # len(results) == 3 # and isinstance(results[0], list) # and isinstance(results[1], int) # and isinstance(results[2], dict) # ): # raise Exception(EXCEPTION_MESSAGE_WRONG_RETURN_TYPE_FIT)
After commenting, now client runs all rounds without breaking.
2) If I am not commented, client initially throws error as follows,
> Exception:
> NumPyClient.fit did not return a tuple with 3 elements.
> The returned values should have the following type signature:
>
> Tuple[List[np.ndarray], int, Dict[str, Scalar]]
Looks like without first fit , client return None or empty tuple. So, control goes to client->grpc-client->connection.py exception block (at Line:118 try: {} finally {}:)
3)So, Flower developers need to check this, whether it is bug or user side issue.
Thanks,
SJayaram