Tensorflow Federated Demo

Hi everyone!

I am trying to use the demo script provided on the tensorflow federated page:

but keep running into errors:

OSError Traceback (most recent call last)
Cell In[1], line 30
26 # Simulate a few rounds of training with the selected client devices.
27 trainer = tff.learning.algorithms.build_weighted_fed_avg(
28 model_fn,
29 client_optimizer_fn=lambda: tf.keras.optimizers.SGD(0.1))
β€”> 30 state = trainer.initialize()
31 for _ in range(5):
32 result = trainer.next(state, train_data)

File /opt/anaconda3/envs/federated_env/lib/python3.10/site-packages/tensorflow_federated/python/core/impl/computation/computation_impl.py:135, in ConcreteComputation.call(self, *args, **kwargs)
133 def call(self, *args, **kwargs):
134 arg = function_utils.pack_args(self._type_signature.parameter, args, kwargs)
β†’ 135 return self._context_stack.current.invoke(self, arg)

File /opt/anaconda3/envs/federated_env/lib/python3.10/site-packages/tensorflow_federated/python/core/impl/execution_contexts/sync_execution_context.py:67, in ExecutionContext.invoke(self, comp, arg)
66 def invoke(self, comp, arg):
β€”> 67 return self._async_runner.run_coro_and_return_result(
68 self._async_context.invoke(comp, arg))

File /opt/anaconda3/envs/federated_env/lib/python3.10/site-packages/tensorflow_federated/python/common_libs/async_utils.py:223, in AsyncThreadRunner.run_coro_and_return_result(self, coro)
221 β€œβ€β€œRuns coroutine in the managed event loop, returning the result.”""
222 future = asyncio.run_coroutine_threadsafe(coro, self._event_loop)
β†’ 223 return future.result()
…
1846 err_msg = os.strerror(errno_num)
β†’ 1847 raise child_exception_type(errno_num, err_msg, err_filename)
1848 raise child_exception_type(err_msg)

OSError: [Errno 8] Exec format error: β€˜/opt/anaconda3/envs/federated_env/lib/python3.10/site-packages/tensorflow_federated/python/core/backends/native/…/…/…/…/data/worker_binary’

I have also tried using tensorflow_federated on google colab but after installing it I run into the following error:

TypeError Traceback (most recent call last)
in
----> 1 import tensorflow_federated

14 frames
/usr/lib/python3.8/typing.py in _type_check(arg, msg, is_argument)
147 return arg
148 if not callable(arg):
β†’ 149 raise TypeError(f"{msg} Got {arg!r:.100}.")
150 return arg
151

TypeError: Callable[[arg, …], result]: each arg must be a type. Got Ellipsis.

I have also tried building the library from source following these steps:

but this is still impossible.

Any ideas on what might be wrong?

Hi @kirkdemeroukas,

Welcome to the TensorFlow Forum!

This is known issue that TF Federated is showing error while installing in local system and team is already working to fix this error. You can install TF Federated module in Google Colab and can run the program.

Please try installing TF Federated using pip as below and install the protobuf 3.20 version after installing the other packages as there are protobuf version mismatch between different Tensorflow packages.

pip install tensorflow-federated
pip install protobuf==3.20

Restart the kernel and run your specified code. Please have a look at this replicated gist of the code in the Google Colab.

Let us know if the issue still persists. Thank you.

1 Like