google-parfait / tensorflow-federated

An open-source framework for machine learning and other computations on decentralized data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: module 'numpy' has no attribute '_no_nep50_warning' when importing TensorFlow Federated

arunrajvakathanam opened this issue · comments

commented

Description:

While trying to use TensorFlow Federated (TFF), I encountered an AttributeError upon importing the tensorflow_federated module. The error message specifically states:

AttributeError: module 'numpy' has no attribute '_no_nep50_warning'
Environment:

Python version: Python 3.10.12

Steps to reproduce:

Run the following Python code:
Python
import tensorflow_federated as tff
Use code with caution. Learn more
Observe the AttributeError message.
Expected behavior:

Importing tensorflow_federated should not cause any errors.

Actual behavior:

The AttributeError message indicates an unexpected internal issue within NumPy, potentially preventing proper initialization of TensorFlow Federated.

source code https://github.com/tensorflow/federated/blob/v0.66.0/docs/tutorials/federated_learning_for_image_classification.ipynb

Same problem for the same source code.

Using the link for Google Colab I got:
CODE1:
!pip install --quiet --upgrade tensorflow-federated
OUPUT_ERROR:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. lida 0.0.10 requires fastapi, which is not installed. lida 0.0.10 requires kaleido, which is not installed. lida 0.0.10 requires python-multipart, which is not installed. lida 0.0.10 requires uvicorn, which is not installed. flax 0.7.5 requires jax>=0.4.19, but you have jax 0.4.14 which is incompatible. google-colab 1.0.0 requires portpicker==1.5.2, but you have portpicker 1.6.0 which is incompatible. ipython-sql 0.5.0 requires sqlalchemy>=2.0, but you have sqlalchemy 1.4.20 which is incompatible.

CODE2:
import collections import numpy as np import tensorflow as tf import tensorflow_federated as tff np.random.seed(0) tff.federated_computation(lambda: 'Hello, World!')()

OUTPUT_ERROR: (getting from import tensorflow_federated)
AttributeError: module 'numpy' has no attribute '_no_nep50_warning'

I tried to solve it installing the required packages hoping better results, but I kept getting version conflicts from many packages.

Same issue, how did you fix that, if ever?

Any updates? I'm facing the same issue.

commented

Commenting in case a solution is available. Facing the same issue with numpy==1.24.4

Sorry for coming in late. The problem you are likely seeing is that the runtime you are using in colab has an older version of numpy or an older version of TFF. Some solutions...

  1. Create your own runtime with only TFF and it's dependencies.
  2. Uninstall the conflicting dependencies and install the correct ones.
  3. You can try installing the new ones over top of the old ones.