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

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


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


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

文章目录:


环境说明:


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

1 问题说明

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

在这里插入图片描述

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 "<stdin>", 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可用!


在这里插入图片描述




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

已标记关键词 清除标记
相关推荐
<div> <h4>Description</h4> <p>I was trying to read about ARIMA models via this link</p> <p>https://medium.com//using-python-and-auto-arima-to-forecast-seasonal-time-series-90877adff03c</p> <p>and while training the model i got the following error</p> <h4>Steps/Code to Reproduce</h4> <h4>Expected Results</h4> <p>The resulting best model parameters should give us an AIC value of 1771.29.</p> <h4>Actual Results</h4> <p>AttributeError Traceback (most recent call last) in () 5 error_action='ignore', 6 suppress_warnings=True, ----> 7 stepwise=True)</p> <p>/anaconda3/lib/python3.6/site-packages/pyramid/arima/auto.py in auto_arima(y, exogenous, start_p, d, start_q, max_p, max_d, max_q, start_P, D, start_Q, max_P, max_D, max_Q, max_order, m, seasonal, stationary, information_criterion, alpha, test, seasonal_test, stepwise, n_jobs, start_params, trend, method, transparams, solver, maxiter, disp, callback, offset_test_args, seasonal_test_args, suppress_warnings, error_action, trace, random, random_state, n_fits, return_valid_fits, out_of_sample_size, scoring, scoring_args, **fit_args) 626 627 # fit a baseline p, d, q model and then a null model --> 628 stepwise_wrapper.fit_increment_k_cache_set(True) # p, d, q, P, D, Q 629 stepwise_wrapper.fit_increment_k_cache_set( 630 True, p=0, q=0, P=0, Q=0) # null model</p> <p>/anaconda3/lib/python3.6/site-packages/pyramid/arima/auto.py in fit_increment_k_cache_set(self, expr, p, q, P, Q) 779 out_of_sample_size=self.out_of_sample_size, 780 scoring=self.scoring, --> 781 scoring_args=self.scoring_args) 782 783 # use the orders as a key to be hashed for</p> <p>/anaconda3/lib/python3.6/site-packages/pyramid/arima/auto.py in _fit_arima(x, xreg, order, seasonal_order, start_params, trend, method, transparams, solver, maxiter, disp, callback, fit_params, suppress_warnings, trace, error_action, out_of_sample_size, scoring, scoring_args) 846 out_of_sample_size=out_of_sample_size, scoring=scoring, 847 scoring_args=scoring_args)\ --> 848 .fit(x, exogenous=xreg, **fit_params) 849 850 # for non-stationarity errors or singular matrices, return None</p> <p>/anaconda3/lib/python3.6/site-packages/pyramid/arima/arima.py in fit(self, y, exogenous, **fit_args) 375 # As of version 0.7.2, start saving the version with the model so 376 # we can track changes over time. --> 377 self.pkg_version_ = pyramid.<strong>version</strong> 378 return self 379 </p> <p>AttributeError: module 'pyramid' has no attribute '<strong>version</strong>'</p> <h4>Versions</h4> <p>1 import pyramid; print("Pyramid", pyramid.<strong>version</strong>)</p> <p>AttributeError: module 'pyramid' has no attribute '<strong>version</strong>'</p> <p>--></p> <p>该提问来源于开源项目:alkaline-ml/pmdarima</p></div>
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:白松林 返回首页