NVIDIA Jetson Xavier NX上导入tensorflow报错:AttributeError: module ‘wrapt‘ has no attribute ‘ObjectProxy‘

欢迎大家关注笔者,你的关注是我持续更博的最大动力


原创文章,转载告知,盗版必究


在Jetson Xavier NX上导入tensorflow报错:AttributeError: module 'wrapt' has no attribute 'ObjectProxy'

文章目录:

  • 1 问题说明
  • 2 解决错误
    • 2.1 找到问题的原因
    • 2.2 最终错误的解决方式


环境说明:


  • NVIDIA Xavier NX 开发板
  • 安装tensorflow==2.3.0

1 问题说明

1、安装显示已经成功安装了tensorflow

NVIDIA Jetson Xavier NX上导入tensorflow报错:AttributeError: module ‘wrapt‘ has no attribute ‘ObjectProxy‘_第1张图片

2、导入tensorflow的时候报错:AttributeError: module 'wrapt' has no attribute 'ObjectProxy'

>>> import tensorflow
2020-10-23 14:09:05.184865: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.2
Traceback (most recent call last):
  File "", line 1, in <module>
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 45, in <module>
    from tensorflow.python import data
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/data/__init__.py", line 25, in <module>
    from tensorflow.python.data import experimental
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/data/experimental/__init__.py", line 96, in <module>
    from tensorflow.python.data.experimental import service
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/data/experimental/service/__init__.py", line 21, in <module>
    from tensorflow.python.data.experimental.ops.data_service_ops import distribute
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 25, in <module>
    from tensorflow.python.data.experimental.ops import compression_ops
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py", line 20, in <module>
    from tensorflow.python.data.util import structure
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/data/util/structure.py", line 26, in <module>
    from tensorflow.python.data.util import nest
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/data/util/nest.py", line 41, in <module>
    from tensorflow.python.framework import sparse_tensor as _sparse_tensor
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/framework/sparse_tensor.py", line 28, in <module>
    from tensorflow.python.framework import composite_tensor
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/framework/composite_tensor.py", line 27, in <module>
    from tensorflow.python.util import nest
  File "/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/util/nest.py", line 1430, in <module>
    _pywrap_utils.RegisterType("ObjectProxy", _wrapt.ObjectProxy)
AttributeError: module 'wrapt' has no attribute 'ObjectProxy'
>>> 

如果你再次导入:import tensorflow as tf,还有可能会出现错误:TypeError: Value already registered for Mapping,反正都是一个问题,请继续看下文吧!

2 解决错误

2.1 找到问题的原因

遇到问题,首先是谷歌、百度,但是结果是没有人遇到这种问题,因此我也就不知道问题该如何解决!

这时候只能从问题的根源寻找问题原因,才能找到解决问题的方式,首先定位到问题出现的代码:/home/zhihui/.local/lib/python3.6/site-packages/tensorflow/python/util/nest.py,于是就到这个文件中去找_wrapt.ObjectProxy,然后通过代码定位到wrapt是一个python的库包

nest.py代码中有导入:

import wrapt as _wrapt

因此我想到这可能是wrapt版本的问题导致的部分属性已经不存在了

1、查看Jetson Xavier NX上安装的wrapt的版本,结果是:1.12.1

zhihui@zhihui-desktop:~$ pip3 show wrapt
Name: wrapt
Version: 1.12.1
Summary: Module for decorators, wrappers and monkey patching.
Home-page: https://github.com/GrahamDumpleton/wrapt
Author: Graham Dumpleton
Author-email: Graham.Dumpleton@gmail.com
License: BSD
Location: /home/zhihui/.local/lib/python3.6/site-packages
Requires: 
Required-by: tensorflow
zhihui@zhihui-desktop:~$ 

2、查看我个人PC上安装wrapt的版本,结果是:1.11.1

C:\Users\93176>pip show wrapt
Name: wrapt
Version: 1.11.1
Summary: Module for decorators, wrappers and monkey patching.
Home-page: https://github.com/GrahamDumpleton/wrapt
Author: Graham Dumpleton
Author-email: Graham.Dumpleton@gmail.com
License: BSD
Location: c:\programdata\anaconda3\lib\site-packages
Requires:
Required-by: -ensorflow-gpu, tensorflow-gpu, astroid

C:\Users\93176>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 wrapt as _wrapt
>>> _wrapt.ObjectProxy
<class 'ObjectProxy'>
>>>

因此确定是wrapt版本的问题

2.2 最终错误的解决方式

1、降低wrapt的版本到1.11.1

pip3 install wrapt==1.11.1

2、再次在NVIDIA Jetson Xavier NX导入tensorflow

```python
zhihui@zhihui-desktop:~$ python
Python 3.6.9 (default, Jul 17 2020, 12:50:27) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-10-23 14:43:46.641605: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.2
>>> 

而且用:tf.test.is_gpu_available() 返回的也是True,即GPU可用!





在这里插入图片描述
♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠

你可能感兴趣的:(16_各种错误和bug(你的痛,我的痛,痛痛痛),Jetson,tensorflow)