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

FutureWarning: Deprecated numpy API calls in tf.python.framework.dtypes #30427

Closed
habernal opened this issue Jul 5, 2019 · 33 comments · Fixed by #30559
Closed

FutureWarning: Deprecated numpy API calls in tf.python.framework.dtypes #30427

habernal opened this issue Jul 5, 2019 · 33 comments · Fixed by #30559
Assignees
Labels
comp:apis Highlevel API related issues stat:awaiting response Status - Awaiting response from author TF 2.0 Issues relating to TensorFlow 2.0 type:support Support issues

Comments

@habernal
Copy link
Contributor

habernal commented Jul 5, 2019

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): not really
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS Mojave 10.14.5 (18F132)
  • TensorFlow installed from (source or binary): tensorflow==2.0.0b1 from https://pypi.org/
  • TensorFlow version (use command below): v2.0.0-beta0-16-g1d91213fe7 2.0.0-beta1
  • Python version: Python 3.6.8
  • Bazel version (if compiling from source): N/A
  • GCC/Compiler version (if compiling from source): N/A
  • CUDA/cuDNN version: N/A
  • GPU model and memory: N/A

Describe the current behavior

A plenty of FutureWarning errors:

/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])

Describe the expected behavior

No warnings.

Code to reproduce the issue

import tensorflow.python.framework.dtypes

print("Hello world")
@ravikyram ravikyram self-assigned this Jul 8, 2019
@ravikyram
Copy link
Contributor

@habernal We have executed your code in Google colab and in Jupyter notebook with TF version
2.0 beta 1 and numpy version 1.16.4.We did not get any warnings.Please upgrade your numpy version and check whether the warnings still persists.Thanks!

@ravikyram ravikyram added comp:apis Highlevel API related issues stat:awaiting response Status - Awaiting response from author labels Jul 8, 2019
@habernal
Copy link
Contributor Author

habernal commented Jul 9, 2019

Thanks, @ravikyram - I've double-checked the installed libraries and found the culprit.

TF 2.0.b1 comes with numpy dependency 1.16.4 and it shows no warning. So it is correct you couldn't reproduce the bug, neither could I.

However, it turned out that I had numpy 1.17.0rc1 installed in the project (no idea from which library it was linked as I certainly didn't install it by hand).

Numpy 1.17.0rc1 is responsible for complaining about these FutureWarnings. Perhaps not urgent to fix for now but once there is an upgrade to np 17, this will show up again, I guess.

@habernal
Copy link
Contributor Author

habernal commented Jul 9, 2019

In fact, the numpy dependency is treated differently given the tool you install TF (pip versus setuptools). Both tested in a clean virtual environment with only these libraries installed at the beginning:

pip==19.1.1 setuptools==41.0.1 wheel==0.33.4

  1. Installing TF using pip:
$ pip install tensorflow==2.0.0b1 --no-cache-dir
...
Collecting numpy<2.0,>=1.14.5 (from tensorflow==2.0.0b1)
  Downloading https://files.pythonhosted.org/packages/...cc/numpy-1.16.4-cp36-cp....whl (13.9MB)
...
  1. Installing TF as dependendy in setup.py containing only:
from setuptools import setup
setup(
    name='tf30427',
    version='0.0.1',
    install_requires=['tensorflow==2.0.0b1'],
)

and then installing as

$ python setup.py install
...
Searching for numpy<2.0,>=1.14.5
Reading https://pypi.org/simple/numpy/
Downloading https://files.pythonhosted.org/packages/e...17/numpy-1.17.0rc1-cp36-cp36...25e0
Best match: numpy 1.17.0rc1
Processing numpy-1.17.0rc1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Installing numpy-1.17.0rc1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl to /xxx/venv/lib/python3.6/site-packages
Adding numpy 1.17.0rc1 to easy-install.pth file
...

They understand the requirement numpy<2.0,>=1.14.5 differently: pip installs 1.16.4 while setuptools 1.17.0rc1.

Proposed fix:

Change the dependency to numpy<1.17,>=1.14.5 to stick with the 1.16 version regardless of the installation procedure.

@habernal
Copy link
Contributor Author

habernal commented Jul 9, 2019

And here's the core of the problem: pypa/setuptools#855

as discovered by others, too: https://stackoverflow.com/q/54796975

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Jul 9, 2019
@ravikyram
Copy link
Contributor

@habernal let me know if we can close this issue since we found the solution. Thanks!

@yongtang
Copy link
Member

@habernal I think tensorflow could be updated to make it compatible with numpy 1.17+. Created a PR #30559 for the fix.

@Akeaakar
Copy link

Hello i am having the same error. Can u plese tell me what to do with instruction to solve this problem.Thanks

@yongtang
Copy link
Member

@Akeaakar The issue has been fixed and merged into the master branch. In the next release of TF the issue should be gone.

@ssomers
Copy link

ssomers commented Jul 28, 2019

@Akeaakar And for the time being, pip install "numpy<1.17" to revert to numpy version 1.16.4

@Zhiwei-Zhai
Copy link

With Ubuntu19.04, the combination of tensorflow-gpu 1.14.0 (or tensorflow-gpu 1.12.2) with numpy 1.17.0 has the same warnings as well. When change numpy version to 1.16.3, the warnings are gone.

wchargin pushed a commit to tensorflow/tensorboard that referenced this issue Jul 31, 2019
This commit integrates upstream changes into TensorBoard’s
`tensorflow_stub` to resolve a deprecation warning in recent release
candidates for NumPy.

Upstream bug: <tensorflow/tensorflow#30427>

Upstream fix: <tensorflow/tensorflow#30559>
@njanirudh
Copy link

njanirudh commented Aug 20, 2019

Or you can supress the warnings using the below code.

import warnings
import tensorflow as tf

warnings.filterwarnings('ignore')

@htuhxf
Copy link

htuhxf commented Aug 30, 2019

Or you can supress the warnings using the below code.

import warnings
import tensorflow as tf

warnings.filterwarnings('ignore')

seems this doesn't work for me. (numpy1.17.0 python3.7.3)

@Gra-tak
Copy link

Gra-tak commented Sep 4, 2019

Or you can supress the warnings using the below code.

import warnings
import tensorflow as tf

warnings.filterwarnings('ignore')

seems this doesn't work for me. (numpy1.17.0 python3.7.3)

import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
import tensorflow as tf

Needs to be before the import, since that is where the warnings are coming from. Also added a restriction to only effect that warning category instead of silencing all warnings.

@Michael-VT
Copy link

import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
import tensorflow as tf
It works for me even under a virtual environment

@csarami
Copy link

csarami commented Sep 13, 2019

I have numpy in ./venv/lib/python3.7/site-packages (1.17.2). In both Jupyter and VS Code, I get the idea. I really dislike the idea of ignoring the warning. Any fixes would be greatly appreciated.

@arianaa30
Copy link

arianaa30 commented Sep 17, 2019

pip install "numpy<1.17"

After doing that, system installed numpy-1.16.5. But now import tensorflow says:
ImportError: Something is wrong with the numpy installation.

@jagadeeshjr5
Copy link

jagadeeshjr5 commented Sep 20, 2019

numpy: pip install --upgrade numpy
keras: conda install -c conda-forge keras

Upgrade your numpy and install keras by using the above command in Anaconda prompt.

@Namburger
Copy link

Hi, for reference, I got this fixed with these 2 version:

>>> import tensorflow as tf
>>> print(tf.__version__)
2.0.0-rc1
>>> import numpy as np
>>> print(np.__version__)
1.17.2
>>> exit()

09/24/19, hope this helps

@askerlee
Copy link

Thanks @Namburger . The warnings are gone on 2.0.0-rc1.

@UndeadKernel
Copy link

With the latest release of tensorflow (i.e., 2.0.0) and numpy 1.17.2, the warning is back.

@mihaimaruseac
Copy link
Collaborator

Can you provide a reproducer, @UndeadKernel ? I cannot reproduce:

>>> import tensorflow as tf
>>> tf.__version__
'2.0.0'
>>> import numpy as np
>>> np.__version__
'1.17.2'
>>> import tensorflow.python.framework.dtypes
>>> 

Also tried from a file:

import tensorflow as tf
import numpy as np

print("TF", tf.__version__)
print("NP", np.__version__)

import tensorflow.python.framework.dtypes

but no warnings:

(gh_numpty) mihaimaruseac@ankh:/tmp/gh_numpty$ python test.py 
TF 2.0.0
NP 1.17.2

@UndeadKernel
Copy link

@mihaimaruseac, I can reproduce the problem with both examples of yours. That is, I see the following output:

2019-10-14 12:20:56.438892: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
/usr/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
TF 2.0.0
NP 1.17.2

I'm using arch. Arch, if I recall correctly, adapts Tensorflow to work with Python 3.7.4. Or is this version of Python already supported by Tensorflow?

@rharish101
Copy link

rharish101 commented Oct 14, 2019

@UndeadKernel I'm running Arch too, but I'm not getting any warnings as of now (they were present earlier). My packages are:

  • python-tensorflow-opt-cuda: 2.0.0-2
  • python-numpy-openblas: 1.17.2-1

@UndeadKernel
Copy link

This is indeed quite strange @rharish101, I have the same exact versions. I tried using python-numpy from the official repo and python-numpy-openblas` from the AUR and I see the same FutureWarning messages.

@rharish101
Copy link

@UndeadKernel Could you try reinstalling the TensorFlow package? It might have changed in the latest patch (2.0.0-2 as opposed to 2.0.0-1). I remember that I, too, saw those warnings in the last few days, but as of today, they are gone, with the only difference that I updated TensorFlow 9 days ago.

@UndeadKernel
Copy link

@rharish101, thank for the suggestion.
I noticed that tensorboard was not the same version as tensorflow. After reinstalling tensorboard (notice that this is "tensorBoard" and not "TensorFlow"), the warning went away.

@mihaimaruseac
Copy link
Collaborator

There is an official release of 2.0, you should not need to use the patched versions.

@UndeadKernel
Copy link

To which patches are you referring @mihaimaruseac?

@mihaimaruseac
Copy link
Collaborator

2.0.0-1 and 2.0.0-2 mentioned in above comments

pip install tensorflow==2.0.0 should work (might need to upgrade pip to the latest version if you're on an old one, due to the change to be manylinux2010 compliant)

MaximeKjaer added a commit to MaximeKjaer/tf-dotty that referenced this issue Oct 29, 2019
felker added a commit to PPPLDeepLearning/plasma-python that referenced this issue Oct 29, 2019
As a test, only suppressing single import of Keras (and hence TF
backend) that occurs when importing conf directly.

Reference:
tensorflow/tensorflow#30427
@Benjamin0000Rodriguez
Copy link

try

pip3 [pip] install tf-nightly

the nightly build of tensorflow seems to have that problem sorted out, best of luck

@FoxerLee
Copy link

FoxerLee commented Dec 2, 2019

for tensorflow==2.0.0 and numpy==1.17.4

I don't get the error/warning.

You can try as:

>>> import tensorflow as tf
>>> tf.__version__
'2.0.0'
>>> import numpy as np
>>> np.__version__
'1.17.4'
>>> import tensorflow.python.framework.dtypes
>>>

@jean-noelp
Copy link

jean-noelp commented Feb 4, 2020

@Akeaakar And for the time being, pip install "numpy<1.17" to revert to numpy version 1.16.4

And also for anaconda:
conda install "numpy<1.17"

@louiselmps
Copy link

And for the time being, pip install "numpy<1.17" to revert to numpy version 1.16.4

After how many hours this was the one that solved my problem. I installed the TF that had the numpy version installed (18.0) and when i reverted it to 1.16.4 it works! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:apis Highlevel API related issues stat:awaiting response Status - Awaiting response from author TF 2.0 Issues relating to TensorFlow 2.0 type:support Support issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.