google-research / federated

A collection of Google research projects related to Federated Learning and Federated Analytics.
Apache License 2.0
693 stars 196 forks source link

AttributeError while trying to run optimization #45

Closed JuiP closed 3 years ago

JuiP commented 3 years ago

Hi, I am currently trying to run :

bazel run :trainer -- --task=emnist_character --total_rounds=100 --client_optimizer=sgd --client_learning_rate=0.1 --client_batch_size=20 --server_optimizer=sgd --server_learning_rate=1.0 --clients_per_round=10 --experiment_name=emnist_fedavg_experiment

The Error I get is:

Traceback (most recent call last):
  File "/home/jui/.cache/bazel/_bazel_jui/6be0c55f2c2ec3b2dd0eade5c0ad91be/execroot/org_federated_research/bazel-out/k8-opt/bin/optimization/trainer.runfiles/org_federated_research/optimization/trainer.py", line 31, in <module>
    from optimization import fed_avg_schedule
  File "/home/jui/.cache/bazel/_bazel_jui/6be0c55f2c2ec3b2dd0eade5c0ad91be/execroot/org_federated_research/bazel-out/k8-opt/bin/optimization/trainer.runfiles/org_federated_research/optimization/fed_avg_schedule.py", line 37, in <module>
    ModelBuilder = Callable[[], tff.learning.Model]
AttributeError: module 'tensorflow_federated' has no attribute 'learning'

And Error2:

Traceback (most recent call last):
  File "/home/jui/.cache/bazel/_bazel_jui/6be0c55f2c2ec3b2dd0eade5c0ad91be/execroot/org_federated_research/bazel-out/k8-opt/bin/optimization/trainer.runfiles/org_federated_research/optimization/trainer.py", line 32, in <module>
    from utils import task_utils
  File "/home/jui/.cache/bazel/_bazel_jui/6be0c55f2c2ec3b2dd0eade5c0ad91be/execroot/org_federated_research/bazel-out/k8-opt/bin/optimization/trainer.runfiles/org_federated_research/utils/task_utils.py", line 25, in <module>
    tff.simulation.baselines.cifar100.create_image_classification_task,
AttributeError: module 'tensorflow_federated' has no attribute 'simulation'

And here is the output of pip freeze of my virtual env:

absl-py==0.12.0
astunparse==1.6.3
attrs==21.2.0
bazel==0.0.0.20200723
cached-property==1.5.2
cachetools==3.1.1
certifi==2021.10.8
charset-normalizer==2.0.7
clang==5.0
cloudpickle==2.0.0
dataclasses==0.8
decorator==5.1.0
dill==0.3.4
dm-tree==0.1.6
flatbuffers==1.12
future==0.18.2
gast==0.4.0
google-auth==1.35.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
googleapis-common-protos==1.53.0
grpcio==1.37.0
h5py==3.1.0
idna==3.3
importlib-metadata==4.8.1
importlib-resources==5.3.0
jax==0.2.17
jaxlib==0.1.69
keras==2.6.0
keras-nightly==2.7.0.dev2021062900
Keras-Preprocessing==1.1.2
libclang==11.1.0
Markdown==3.3.4
mpmath==1.2.1
numpy==1.19.5
oauthlib==3.1.1
opt-einsum==3.3.0
pandas==1.1.5
portpicker==1.3.9
promise==2.3
protobuf==3.19.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
python-dateutil==2.8.2
pytz==2021.3
requests==2.26.0
requests-oauthlib==1.3.0
retrying==1.3.3
rsa==4.7.2
scipy==1.1.0
semantic-version==2.8.5
six==1.15.0
tb-nightly==2.6.0a20210806
tensorboard==2.7.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.0
tensorflow==2.6.0
tensorflow-addons==0.14.0
tensorflow-datasets==4.4.0
tensorflow-estimator==2.6.0
tensorflow-federated-nightly==0.19.0.dev20210901
tensorflow-hub==0.12.0
tensorflow-metadata==1.2.0
tensorflow-model-optimization==0.5.0
tensorflow-privacy==0.7.3
tensorflow-probability==0.14.1
tensorflow-text-nightly==2.7.0.dev20210811
termcolor==1.1.0
tf-estimator-nightly==2.7.0.dev2021092408
tf-nightly==2.7.0.dev20210806
tfa-nightly==0.15.0.dev20211014164307
tqdm==4.28.1
typeguard==2.13.0
typing-extensions==3.7.4.3
urllib3==1.26.7
Werkzeug==2.0.2
wrapt==1.12.1
zipp==3.6.0

I suspect these errors are due to package version differences. However, I am unable to find the exact package that's causing the errors. Also, I'm using tensorflow-federated-nightly==0.19.0.dev20210901 as suggested in other issues.

JuiP commented 3 years ago

I was using python3.6, upgraded to Python3.8 and seems to have fixed the issue.