Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'tensorflow_federated.python.core.backends.native' has no attribute 'set_sync_local_execution_context' #3792

Open
deepquantum88 opened this issue Mar 26, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@deepquantum88
Copy link

Describe the bug
Trying to run TFF with differential privacy module, but it throws an attribute error.

Environment (please complete the following information):

  • python=3.8.16
  • Tensorflow: 2.7.0
  • TFF: 0.19.0

I cannot use python 3.9 or TF >2.7.0 due to compatibility with other packages. How can i use module 'tensorflow_federated.python.core.backends.native' 'set_sync_local_execution_context'. Is there any alternative or am missing something. Please help.

@deepquantum88 deepquantum88 added the bug Something isn't working label Mar 26, 2023
@huili0140
Copy link
Collaborator

Thank you for the question, we're looking into this.

@huili0140
Copy link
Collaborator

Hi, it looks like the TFF version you used is an very old version, it's a version we released about 2 years ago. The TFF tutorials and TFF API docs are all based on the newer versions. Are you copying the tutorial from Colab and run it locally?

@deepquantum88
Copy link
Author

Hi, I used TFF version 0.48.0, but still it did not work. It only works if tff is 0.52.0 with python 3.9.
Due to python dependency, I am not able to use python>3.8.16.

Is there any alternative solution for the above code?

@huili0140
Copy link
Collaborator

Could you try approaches such as:

  1. Pure python solution - import the symbol, and invoke dir, in this case

import tensorflow_federated as tff
print(dir(tff.backends.native)) # where did my functions go?

  1. Look at the source at that point in time https://github.com/tensorflow/federated/blob/v0.19.0/tensorflow_federated/python/core/backends/native/__init__.py

@deepquantum88
Copy link
Author

Hi, I tried tff.aggregator differential privacy from https://www.tensorflow.org/federated/tutorials/tuning_recommended_aggregators

But it did not work.

I seen in github tff release that tff.aggregators can work in tff 2.19.0 version and tf 2.7.0 and python 3.8.16.
https://github.com/tensorflow/federated/blob/main/RELEASE.md

dp_mean = tff.aggregators.DifferentiallyPrivateFactory.gaussian_adaptive(
noise_multiplier=0.1, clients_per_round=100)

But it throws an error that tff has no attribute aggregators.

Else what can be the minimum version of tff to work with aggregators.

can you please look in to this.

@zcharles8
Copy link
Collaborator

@deepquantum88 TFF did have an aggregators API, even in version 0.19, see https://github.com/tensorflow/federated/tree/v0.19.0/tensorflow_federated/python/aggregators.

Also note that you can directly look atthe aggregators tutorial associated with v0.19.0, see https://github.com/tensorflow/federated/tree/v0.19.0/docs/tutorials.

Since this is a different bug than the one you initially filed above, can you please fill out the bug template form (reproduced below)? Better yet, a separate bug thread, as these are two separate issues, would be useful.


Describe the bug
A clear and concise description of what the bug is. It is often helpful to
provide a link to a colab notebook that
reproduces the bug.

Environment (please complete the following information):

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • Python package versions (e.g., TensorFlow Federated, TensorFlow):
  • Python version:
  • Bazel version (if building from source):
  • CUDA/cuDNN version:
  • What TensorFlow Federated execution stack are you using?

Note: You can collect the Python package information by running pip3 freeze
from the command line and most of the other information can be collected using
TensorFlows environment capture
script.

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

@deepquantum88
Copy link
Author

deepquantum88 commented Apr 6, 2023

@zcharles8 @huili0140
I tried to execute tff.learning.dp_aggregator in aggregator. But when i initialize iterative process, it stuck (like in loop)

dp_mean = tff.aggregators.DifferentiallyPrivateFactory.gaussian_adaptive(
noise_multiplier=0.1, clients_per_round=4)

iterative_process = tff.learning.algorithms.build_unweighted_fed_avg(
my_model_fn,
client_optimizer_fn=lambda: tf.keras.optimizers.SGD(0.01),
server_optimizer_fn=lambda: tf.keras.optimizers.SGD(1.0, momentum=0.9),
model_aggregator=dp_mean)

state = iterative_process.initialize()

When i am executing the above initialize statement, it keeps on executing and look like in infinite loop.

Python=3.9.7
TF=2.11.0
TFF=0.48.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants