Informação do sistema
Descreva o comportamento atual
Muitos erros FutureWarning:
/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)])
Descreva o comportamento esperado
Sem avisos.
Código para reproduzir o problema
import tensorflow.python.framework.dtypes
print("Hello world")
@habernal Executamos seu código no Google colab e no notebook Jupyter com versão TF
2.0 beta 1 e versão numpy 1.16.4. Não recebemos nenhum aviso. Atualize sua versão numpy e verifique se os avisos ainda persistem. Obrigado!
Obrigado, @ravikyram -
TF 2.0.b1 vem com dependência numpy 1.16.4 e não mostra nenhum aviso. Portanto, é correto que você não conseguiu reproduzir o bug, nem eu.
No entanto, descobri que eu tinha o numpy 1.17.0rc1 instalado no projeto (não tenho ideia de qual biblioteca ele estava vinculado, pois certamente não o instalei manualmente).
Numpy 1.17.0rc1 é responsável por reclamar dessas FutureWarnings. Talvez não seja urgente consertar por enquanto, mas assim que houver uma atualização para o np 17, isso aparecerá novamente, eu acho.
Na verdade, a dependência numpy é tratada de forma diferente dada a ferramenta que você instalou TF ( pip
versus setuptools
). Ambos testados em um ambiente virtual limpo com apenas estas bibliotecas instaladas no início:
pip==19.1.1
setuptools==41.0.1
wheel==0.33.4
$ 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)
...
setup.py
contendo apenas:from setuptools import setup
setup(
name='tf30427',
version='0.0.1',
install_requires=['tensorflow==2.0.0b1'],
)
e então instalando como
$ 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
...
Eles entendem o requisito numpy<2.0,>=1.14.5
diferente: pip instala 1.16.4 enquanto setuptools 1.17.0rc1.
Correção proposta:
Mude a dependência para numpy<1.17,>=1.14.5
para manter a versão 1.16 independentemente do procedimento de instalação.
E aqui está o cerne do problema: https://github.com/pypa/setuptools/issues/855
como descoberto por outros também: https://stackoverflow.com/q/54796975
@habernal deixe-me saber se podemos resolver este problema, uma vez que encontramos a solução. Obrigado!
@habernal Acho que o tensorflow poderia ser atualizado para torná-lo compatível com o numpy 1.17+. Criou um PR # 30559 para a correção.
Olá estou tendo o mesmo erro. Você pode me dizer o que fazer com as instruções para resolver este problema. Obrigado
@Akeaakar O problema foi corrigido e incorporado ao branch master. Na próxima versão do TF, o problema deve ter desaparecido.
@Akeaakar E por enquanto, pip install "numpy<1.17"
para reverter para a versão 1.16.4 numpy
Com o Ubuntu19.04, a combinação de tensorflow-gpu 1.14.0 (ou tensorflow-gpu 1.12.2) com numpy 1.17.0 também tem os mesmos avisos. Ao alterar a versão numpy para 1.16.3, os avisos desaparecem.
Ou você pode suprimir os avisos usando o código abaixo.
import warnings
import tensorflow as tf
warnings.filterwarnings('ignore')
Ou você pode suprimir os avisos usando o código abaixo.
import warnings import tensorflow as tf warnings.filterwarnings('ignore')
parece que isso não funciona para mim. (numpy1.17.0 python3.7.3)
Ou você pode suprimir os avisos usando o código abaixo.
import warnings import tensorflow as tf warnings.filterwarnings('ignore')
parece que isso não funciona para mim. (numpy1.17.0 python3.7.3)
import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
import tensorflow as tf
Precisa ser antes da importação, pois é daí que vêm os avisos. Também foi adicionada uma restrição para afetar apenas essa categoria de aviso, em vez de silenciar todos os avisos.
avisos de importação
warnings.filterwarnings ('ignorar', categoria = FutureWarning)
importar tensorflow como tf
Funciona para mim mesmo em um ambiente virtual
Tenho numpy em ./venv/lib/python3.7/site-packages (1.17.2). Tanto no Jupyter quanto no VS Code, eu entendi a ideia. Realmente não gosto da ideia de ignorar o aviso. Quaisquer correções serão muito apreciadas.
pip install "numpy <1,17"
Depois de fazer isso, o sistema instalou numpy-1.16.5
. Mas agora import tensorflow
diz:
ImportError: Something is wrong with the numpy installation.
numpy: pip install --upgrade numpy
keras: conda install -c conda-forge keras
Atualize seu numpy e instale keras usando o comando acima no prompt do Anaconda.
Olá, para referência, resolvi isso com estas 2 versões:
>>> import tensorflow as tf
>>> print(tf.__version__)
2.0.0-rc1
>>> import numpy as np
>>> print(np.__version__)
1.17.2
>>> exit()
24/09/19, espero que isso ajude
Obrigado @Namburger . Os avisos desapareceram em 2.0.0-rc1.
Com a versão mais recente do tensorflow (ou seja, 2.0.0) e numpy 1.17.2, o aviso está de volta.
Você pode fornecer um reprodutor, @UndeadKernel ? Não consigo reproduzir:
>>> import tensorflow as tf
>>> tf.__version__
'2.0.0'
>>> import numpy as np
>>> np.__version__
'1.17.2'
>>> import tensorflow.python.framework.dtypes
>>>
Também tentei a partir de um arquivo:
import tensorflow as tf
import numpy as np
print("TF", tf.__version__)
print("NP", np.__version__)
import tensorflow.python.framework.dtypes
mas sem avisos:
(gh_numpty) mihaimaruseac<strong i="13">@ankh</strong>:/tmp/gh_numpty$ python test.py
TF 2.0.0
NP 1.17.2
@mihaimaruseac , posso reproduzir o problema com os dois exemplos seus. Ou seja, vejo a seguinte saída:
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
Estou usando o arco. Arch, se bem me lembro, adapta Tensorflow para funcionar com Python 3.7.4. Ou esta versão do Python já é compatível com o Tensorflow?
@UndeadKernel Estou executando o Arch também, mas não estou recebendo nenhum aviso no momento (eles estavam presentes antes). Meus pacotes são:
Isso é realmente muito estranho @ rharish101 , tenho exatamente as mesmas versões. Tentei usar python-numpy
do repo oficial e python-numpy-openblas` do AUR e vejo as mesmas mensagens FutureWarning.
@UndeadKernel Você poderia tentar reinstalar o pacote TensorFlow? Ele pode ter mudado no patch mais recente (2.0.0-2 em oposição ao 2.0.0-1). Lembro que também vi esses avisos nos últimos dias, mas a partir de hoje eles sumiram, com a única diferença de que atualizei o TensorFlow há 9 dias.
@ rharish101 , obrigado pela sugestão.
Notei que tensorboard
não era a mesma versão de tensorflow
. Depois de reinstalar tensorboard
(observe que este é "tensorBoard" e não "TensorFlow"), o aviso foi embora.
Existe um lançamento oficial do 2.0, você não deve precisar usar as versões corrigidas.
A quais patches você está se referindo a @mihaimaruseac?
2.0.0-1 e 2.0.0-2 mencionados nos comentários acima
pip install tensorflow==2.0.0
deve funcionar (pode ser necessário atualizar o pip para a versão mais recente se você estiver em uma versão antiga, devido à mudança para ser compatível com o manylinux2010)
Experimente
pip3 [pip] instalar tf-nightly
a construção noturna do tensorflow parece ter resolvido o problema, boa sorte
para tensorflow==2.0.0
e numpy==1.17.4
Não recebo o erro / aviso.
Você pode tentar como:
>>> import tensorflow as tf
>>> tf.__version__
'2.0.0'
>>> import numpy as np
>>> np.__version__
'1.17.4'
>>> import tensorflow.python.framework.dtypes
>>>
@Akeaakar E por enquanto,
pip install "numpy<1.17"
para reverter para a versão 1.16.4 numpy
E também para anaconda:
conda install "numpy<1.17"
E por enquanto,
pip install "numpy<1.17"
para reverter para a versão 1.16.4 numpy
Depois de quantas horas foi isso que resolveu meu problema. Instalei o TF que tinha a versão numpy instalada (18.0) e quando reverti para 1.16.4 funciona! obrigado
Comentários muito úteis
@Akeaakar E por enquanto,
pip install "numpy<1.17"
para reverter para a versão 1.16.4 numpy