AttributeError: module 'onnx' has no attribute 'export'
时间: 2023-09-23 14:10:16 浏览: 32
这个错误通常是由于onnx库的版本问题引起的。请确保您使用的是支持onnx.export()函数的onnx版本。您可以通过以下命令更新onnx库:
```
pip install -U onnx
```
如果您已经安装了最新版本的onnx库,但仍然遇到此错误,则可能需要检查您的代码中是否存在任何导入onnx模块的语句,并确保没有导入名称与onnx模块冲突的其他模块。
相关问题
AttributeError: module 'mmcv' has no attribute 'Config'
这个错误是由于最新版本的mmcv模块不再支持Config类导致的。[2为了解决这个问题,你需要安装mmengine模块,并将原先的`import mmcv`改成`import mmengine`。更多详细信息可以参考这个链接:https://github.com/open-mmlab/mmdeploy/issues/1781。此外,你还需要在命令行中输入`export CUDA_HOME=/usr/local/cuda-11.7`命令。
此外,还有一点需要注意的是,关于pytest断言报错的问题,你需要使用pytest运行代码,而不是直接运行assume函数。这样才能避免出现报错。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [AttributeError: module ‘mmcv‘ has no attribute ‘Config](https://blog.csdn.net/weixin_46309234/article/details/131015173)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Pytest断言报错:AttributeError: module pytest has no attribute assume](https://blog.csdn.net/weixin_51190396/article/details/131665172)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
AttributeError: module 'torch.fx' has no attribute 'export'
这个错误通常是因为你的 PyTorch 版本太低,不支持 `torch.fx.export` 函数。这个函数是在 PyTorch 1.8.0 版本中加入的,如果你的 PyTorch 版本低于这个版本,就会出现这个错误。
你可以通过以下命令来查看 PyTorch 版本:
```
import torch
print(torch.__version__)
```
如果版本低于 1.8.0,你需要升级 PyTorch 到最新版本。可以使用以下命令来升级:
```
pip install torch -U
```
注意,这个命令会升级 PyTorch 到最新版本,可能会改变一些 API 的行为,需要谨慎使用。如果你想保持当前 PyTorch 版本不变,可以指定要升级到的版本号,例如:
```
pip install torch==1.8.0 -U
```
这样就可以安装 PyTorch 1.8.0 版本了。