ImportError: cannot import name _new_empty_tensor from torchvision.ops (/home/wit/anaconda3/envs/sr/lib/python3.9/site-packages/torchvision/ops/__init__.py)
时间: 2023-08-04 09:04:47 浏览: 1167
根据引用\[1\]和引用\[2\]的报错信息,出现了无法从torchvision.ops中导入_new_empty_tensor和_NewEmptyTensorOp的错误。这可能是因为在torchvision的ops模块中找不到这些名称。根据引用\[3\]中的注释,官方版本已经更新了,为了解决pytorch和torchvision 0.5中的空张量错误,需要导入_new_empty_tensor和_output_size。因此,您可能需要检查您的torchvision和pytorch版本是否符合要求。如果您的版本低于0.7,您可以尝试更新torchvision和pytorch到最新版本,或者按照引用\[3\]中的代码进行导入。如果您的版本已经是0.7或更高,那么可能存在其他问题,您可以尝试重新安装torchvision或查看其他可能的解决方案。
#### 引用[.reference_title]
- *1* [Python问题: cannot import name ‘_new_empty_tensor‘ from ‘torchvision.ops](https://blog.csdn.net/a1228136188/article/details/118891791)[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^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [解决cannot import name ‘_NewEmptyTensorOp‘ from ‘torchvision.ops.misc](https://blog.csdn.net/y96q1023/article/details/78498894)[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^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)