English 中文(简体)
AttributeError: model tensorflow has no Depende keras in conda Immediate
原标题:AttributeError: module tensorflow has no attribute keras in conda prompt

我试图安装帐篷和煤炭。

我安装了帐篷,我进口了该帐篷,没有错误。

安装了Keras,但我可以进口

(base) C:Windowssystem32>pip uninstall keras
Found existing installation: Keras 2.3.1
Uninstalling Keras-2.3.1:
  Would remove:
    c:usersasusanaconda3anacondalibsite-packagesdocs*
    c:usersasusanaconda3anacondalibsite-packageskeras-2.3.1.dist-info*
    c:usersasusanaconda3anacondalibsite-packageskeras*
Proceed (y/n)? y
  Successfully uninstalled Keras-2.3.1

(base) C:Windowssystem32>pip install keras
Collecting keras
  Using cached Keras-2.3.1-py2.py3-none-any.whl (377 kB)
Requirement already satisfied: six>=1.9.0 in c:usersasusanaconda3anacondalibsite-packages (from keras) (1.14.0)
Requirement already satisfied: numpy>=1.9.1 in c:usersasusanaconda3anacondalibsite-packages (from keras) (1.18.4)
Requirement already satisfied: keras-applications>=1.0.6 in c:usersasusanaconda3anacondalibsite-packages (from keras) (1.0.8)
Requirement already satisfied: keras-preprocessing>=1.0.5 in c:usersasusanaconda3anacondalibsite-packages (from keras) (1.1.2)
Requirement already satisfied: scipy>=0.14 in c:usersasusanaconda3anacondalibsite-packages (from keras) (1.4.1)
Requirement already satisfied: pyyaml in c:usersasusanaconda3anacondalibsite-packages (from keras) (5.3.1)
Requirement already satisfied: h5py in c:usersasusanaconda3anacondalibsite-packages (from keras) (2.10.0)
Installing collected packages: keras
Successfully installed keras-2.3.1

接着,我尝试

(base) C:Windowssystem32>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> from keras.models import sequential
Using TensorFlow backend.
2020-05-21 10:03:38.204077: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cudart64_101.dll ; dlerror: cudart64_101.dll not found
2020-05-21 10:03:38.210602: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskeras\__init__.py", line 3, in <module>
    from . import utils
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasutils\__init__.py", line 26, in <module>
    from .vis_utils import model_to_dot
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasutilsvis_utils.py", line 7, in <module>
    from ..models import Model
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasmodels.py", line 10, in <module>
    from .engine.input_layer import Input
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasengine\__init__.py", line 8, in <module>
    from .training import Model
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasengine	raining.py", line 14, in <module>
    from . import training_utils
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasengine	raining_utils.py", line 17, in <module>
    from .. import metrics as metrics_module
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasmetrics.py", line 1850, in <module>
    BaseMeanIoU = tf.keras.metrics.MeanIoU
AttributeError: module  tensorflow  has no attribute  keras 
>>> from keras.models import Sequential
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskeras\__init__.py", line 3, in <module>
    from . import utils
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasutils\__init__.py", line 26, in <module>
    from .vis_utils import model_to_dot
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasutilsvis_utils.py", line 7, in <module>
    from ..models import Model
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasmodels.py", line 12, in <module>
    from .engine.training import Model
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasengine\__init__.py", line 8, in <module>
    from .training import Model
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasengine	raining.py", line 14, in <module>
    from . import training_utils
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasengine	raining_utils.py", line 17, in <module>
    from .. import metrics as metrics_module
  File "C:UsersASUSAnaconda3Anacondalibsite-packageskerasmetrics.py", line 1850, in <module>
    BaseMeanIoU = tf.keras.metrics.MeanIoU
AttributeError: module  tensorflow  has no attribute  keras 

我尝试:

pip install --upgrade --no-deps --force-reinstall tensorflow

pip install --upgrade pip setuptools wheel

pip uninstall protobuf

pip install protobuf

pip install termcolor

我已:

keras                     2.3.1                    pypi_0    pypi

keras-applications        1.0.8                    pypi_0    pypi

keras-preprocessing       1.1.2                    pypi_0    pypi

keyring                   21.1.1                   py36_2

kivy                      1.10.1.dev0              pypi_0    pypi

kivy-deps-glew            0.2.0                    pypi_0    pypi

kivy-deps-gstreamer       0.2.0                    pypi_0    pypi

kivy-deps-sdl2            0.2.0                    pypi_0    pypi

kivy-garden               0.1.4                    pypi_0    pypi

kiwisolver                1.2.0            py36h74a9793_0

lazy-object-proxy         1.4.3            py36he774522_0

我有 n、粉碎、花板、帐篷和大部分洗衣、手机、小口径汽车、小口径汽车、Ai、DS图书馆。

(base) C:UsersASUS>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import tensorflow
2020-05-22 06:23:19.327748: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cudart64_101.dll ; dlerror: cudart64_101.dll not found
2020-05-22 06:23:19.343057: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
>>> print(tensorflow)
<module  tensorflow  from  C:\Users\ASUS\Anaconda3\Anaconda\lib\site-packages\tensorflow\__init__.py >
>>>

当我管理帐篷时

(base) C:UsersASUS>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow.compat.v1 as tf
2020-05-22 06:18:12.900849: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cudart64_101.dll ; dlerror: cudart64_101.dll not found
2020-05-22 06:18:12.914907: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
>>> tf.disable_v2_behavior()
WARNING:tensorflow:From C:UsersASUSAnaconda3Anacondalibsite-packages	ensorflowpythoncompatv2_compat.py:96: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
>>> hello = tf.constant( Hello, TensorFlow! )
>>> sess = tf.compat.v1.Session()
2020-05-22 06:20:28.305196: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-05-22 06:20:29.278356: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 computeCapability: 6.1
coreClock: 1.493GHz coreCount: 5 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-05-22 06:20:29.295408: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cudart64_101.dll ; dlerror: cudart64_101.dll not found
2020-05-22 06:20:29.305186: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cublas64_10.dll ; dlerror: cublas64_10.dll not found
2020-05-22 06:20:29.314235: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cufft64_10.dll ; dlerror: cufft64_10.dll not found
2020-05-22 06:20:29.323997: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  curand64_10.dll ; dlerror: curand64_10.dll not found
2020-05-22 06:20:29.336231: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cusolver64_10.dll ; dlerror: cusolver64_10.dll not found
2020-05-22 06:20:29.349522: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cusparse64_10.dll ; dlerror: cusparse64_10.dll not found
2020-05-22 06:20:29.362633: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library  cudnn64_7.dll ; dlerror: cudnn64_7.dll not found
2020-05-22 06:20:29.372823: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1598] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2020-05-22 06:20:29.392493: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-05-22 06:20:29.413844: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x18bf4dc2f60 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-05-22 06:20:29.424116: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-05-22 06:20:29.432117: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-22 06:20:29.446877: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]
>>> print(sess.run(hello))
b Hello, TensorFlow! 

After I Solve it Check my answer below

(base) C:UsersASUS>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-05-29 17:59:47.814562: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
>>> import keras
Using TensorFlow backend.
>>> from keras.models import Sequential
>>> tf.test.is_built_with_cuda()
True
>>> tf.config.list_physical_devices( GPU )
2020-05-29 18:02:56.764618: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-05-29 18:02:57.602680: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 computeCapability: 6.1
coreClock: 1.493GHz coreCount: 5 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-05-29 18:02:57.607142: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-05-29 18:02:57.703213: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-05-29 18:02:57.766722: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-05-29 18:02:57.797062: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-05-29 18:02:57.872961: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-05-29 18:02:57.920469: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-05-29 18:02:58.035860: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-05-29 18:02:58.148699: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
[PhysicalDevice(name= /physical_device:GPU:0 , device_type= GPU )]
>>> tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)
2020-05-29 18:03:43.187834: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 computeCapability: 6.1
coreClock: 1.493GHz coreCount: 5 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-05-29 18:03:43.200093: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-05-29 18:03:43.205083: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-05-29 18:03:43.214701: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-05-29 18:03:43.217616: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-05-29 18:03:43.229945: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-05-29 18:03:43.238134: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-05-29 18:03:43.247848: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-05-29 18:03:43.256302: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2020-05-29 18:03:43.264822: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-29 18:03:43.269994: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0
2020-05-29 18:03:43.271951: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N
2020-05-29 18:03:43.275672: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/device:GPU:0 with 2993 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1)
True
>>>
最佳回答
问题回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...