facebookresearch/FLSim

Unable to run the tutorial: DataLoader error

dimasquest opened this issue ยท 0 comments

๐Ÿ› Bug

When trying to run any tutorial (or more concretely when importing the FLSim's DataLoader), the following error is raised:

Traceback (most recent call last):
  File "/Users/dima/Documents/FLSim/examples/cifar10_example.py", line 18, in <module>
    import flsim.configs  # noqa
    ^^^^^^^^^^^^^^^^^^^^
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/site-packages/flsim/configs/__init__.py", line 16, in <module>
    import flsim.trainers  # noqa
    ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/site-packages/flsim/trainers/__init__.py", line 10, in <module>
    from .async_trainer import AsyncTrainerConfig
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/site-packages/flsim/trainers/async_trainer.py", line 15, in <module>
    from flsim.clients.async_client import AsyncClientDevice
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/site-packages/flsim/clients/__init__.py", line 10, in <module>
    from .base_client import ClientConfig
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/site-packages/flsim/clients/base_client.py", line 27, in <module>
    from flsim.common.logger import Logger
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/site-packages/flsim/common/__init__.py", line 10, in <module>
    from .timeout_simulator import (
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/site-packages/flsim/common/timeout_simulator.py", line 245, in <module>
    @dataclass
     ^^^^^^^^^
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/dataclasses.py", line 1223, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/dataclasses.py", line 1213, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dima/miniconda3/envs/flsim/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'flsim.utils.timing.training_duration_distribution.PerExampleGaussianDurationDistributionConfig'> for field duration_distribution_generator is not allowed: use default_factory

To Reproduce

โš ๏ธ We cannot help you without you sharing reproducible code. Do not ignore this part :)
Steps to reproduce the behavior:

This is reproducible in either the cifar10_example notebook or script.

  1. python cifar10_example.py

Alternative: in the notebook the following code throws the same error

from flsim.data.data_sharder import SequentialSharder
from flsim.utils.example_utils import DataLoader, DataProvider

2. Create a sharder, which maps samples in the training data to clients.

sharder = SequentialSharder(examples_per_shard=EXAMPLES_PER_USER)

Expected behavior

Environment

Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).

absl-py 1.4.0 pypi_0 pypi
antlr4-python3-runtime 4.9.3 pypi_0 pypi
appnope 0.1.3 pypi_0 pypi
asttokens 2.2.1 pypi_0 pypi
backcall 0.2.0 pypi_0 pypi
bzip2 1.0.8 h620ffc9_4
ca-certificates 2023.01.10 hca03da5_0
cachetools 5.3.0 pypi_0 pypi
certifi 2023.5.7 pypi_0 pypi
charset-normalizer 3.1.0 pypi_0 pypi
comm 0.1.3 pypi_0 pypi
contourpy 1.0.7 pypi_0 pypi
cycler 0.11.0 pypi_0 pypi
debugpy 1.6.7 pypi_0 pypi
decorator 5.1.1 pypi_0 pypi
executing 1.2.0 pypi_0 pypi
filelock 3.12.0 pypi_0 pypi
flsim 0.1.0 pypi_0 pypi
fonttools 4.39.4 pypi_0 pypi
google-auth 2.18.0 pypi_0 pypi
google-auth-oauthlib 1.0.0 pypi_0 pypi
grpcio 1.54.2 pypi_0 pypi
hydra-core 1.3.2 pypi_0 pypi
idna 3.4 pypi_0 pypi
iniconfig 2.0.0 pypi_0 pypi
ipykernel 6.23.0 pypi_0 pypi
ipython 8.13.2 pypi_0 pypi
jedi 0.18.2 pypi_0 pypi
jinja2 3.1.2 pypi_0 pypi
joblib 1.2.0 pypi_0 pypi
jupyter-client 8.2.0 pypi_0 pypi
jupyter-core 5.3.0 pypi_0 pypi
kiwisolver 1.4.4 pypi_0 pypi
libffi 3.4.4 hca03da5_0
markdown 3.4.3 pypi_0 pypi
markupsafe 2.1.2 pypi_0 pypi
matplotlib 3.7.1 pypi_0 pypi
matplotlib-inline 0.1.6 pypi_0 pypi
mpmath 1.3.0 pypi_0 pypi
ncurses 6.4 h313beb8_0
nest-asyncio 1.5.6 pypi_0 pypi
networkx 3.1 pypi_0 pypi
numpy 1.24.3 pypi_0 pypi
oauthlib 3.2.2 pypi_0 pypi
omegaconf 2.3.0 pypi_0 pypi
opacus 1.4.0 pypi_0 pypi
openssl 1.1.1t h1a28f6b_0
opt-einsum 3.3.0 pypi_0 pypi
packaging 23.1 pypi_0 pypi
pandas 2.0.1 pypi_0 pypi
parso 0.8.3 pypi_0 pypi
pexpect 4.8.0 pypi_0 pypi
pickleshare 0.7.5 pypi_0 pypi
pillow 9.5.0 pypi_0 pypi
pip 23.0.1 py311hca03da5_0
platformdirs 3.5.1 pypi_0 pypi
pluggy 1.0.0 pypi_0 pypi
prompt-toolkit 3.0.38 pypi_0 pypi
protobuf 4.23.0 pypi_0 pypi
psutil 5.9.5 pypi_0 pypi
ptyprocess 0.7.0 pypi_0 pypi
pure-eval 0.2.2 pypi_0 pypi
pyasn1 0.5.0 pypi_0 pypi
pyasn1-modules 0.3.0 pypi_0 pypi
pygments 2.15.1 pypi_0 pypi
pyparsing 3.0.9 pypi_0 pypi
pytest 7.3.1 pypi_0 pypi
python 3.11.3 hc0d8a6c_0
python-dateutil 2.8.2 pypi_0 pypi
pytz 2023.3 pypi_0 pypi
pyyaml 6.0 pypi_0 pypi
pyzmq 25.0.2 pypi_0 pypi
readline 8.2 h1a28f6b_0
requests 2.30.0 pypi_0 pypi
requests-oauthlib 1.3.1 pypi_0 pypi
rsa 4.9 pypi_0 pypi
scikit-learn 1.2.2 pypi_0 pypi
scipy 1.10.1 pypi_0 pypi
setuptools 66.0.0 py311hca03da5_0
six 1.16.0 pypi_0 pypi
sqlite 3.41.2 h80987f9_0
stack-data 0.6.2 pypi_0 pypi
sympy 1.12 pypi_0 pypi
tensorboard 2.13.0 pypi_0 pypi
tensorboard-data-server 0.7.0 pypi_0 pypi
threadpoolctl 3.1.0 pypi_0 pypi
tk 8.6.12 hb8d0fd4_0
torch 2.0.1 pypi_0 pypi
torchvision 0.15.2 pypi_0 pypi
tornado 6.3.2 pypi_0 pypi
tqdm 4.65.0 pypi_0 pypi
traitlets 5.9.0 pypi_0 pypi
typing-extensions 4.5.0 pypi_0 pypi
tzdata 2023.3 pypi_0 pypi
urllib3 1.26.15 pypi_0 pypi
wcwidth 0.2.6 pypi_0 pypi
werkzeug 2.3.4 pypi_0 pypi
wheel 0.38.4 py311hca03da5_0
xz 5.4.2 h80987f9_0
zlib 1.2.13 h5a0b063_0

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
  • PyTorch Version (e.g., 1.0):
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

Pytorch 2.0, no CUDA, Mac OS, Python 3.11, miniconda3