from mmcv.ops import RoIPool报错

在安装了mmcv-full=1.4.0并尝试导入RoIPool时遇到找不到指定模块的错误。可能的原因是MMCV库、PyTorch或CUDA版本不匹配,或者Pillow库版本过高。建议检查安装命令的URL,确保版本对应,并尝试降级Pillow到6.2.1版本。如果问题依然存在,可能需要卸载并重新安装MMCV。
部署运行你感兴趣的模型镜像

使用以下命令安装mmcv库以后:

pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.8.0/index.html

尝试导入RolPool库

from mmcv.ops import RoIPool

报错找不到指定模块:

details: Traceback (most recent call last):
File "tools/train.py", line 17, in
from mmocr.apis import train_detector
File "e:\mmlab\mmocr-0.3.0\mmocr\apis_init_.py", line 2, in
from .inference import init_detector, model_inference
File "e:\mmlab\mmocr-0.3.0\mmocr\apis\inference.py", line 7, in
from mmcv.ops import RoIPool
File "D:\Miniconda3\envs\mmlab\lib\site-packages\mmcv\ops_init_.py", line 2, in
from .assign_score_withk import assign_score_withk
File "D:\Miniconda3\envs\mmlab\lib\site-packages\mmcv\ops\assign_score_withk.py", line 6, in
'ext', ['assign_score_withk_forward', 'assign_score_withk_backward'])
File "D:\Miniconda3\envs\mmlab\lib\site-packages\mmcv\utils\ext_loader.py", line 14, in load_ext
ext = importlib.import_module('mmcv.' + name)
File "D:\Miniconda3\envs\mmlab\lib\importlib_init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: 找不到指定的模块。

有两种可能:

  1. 安装的MMCV库和PyTorch、CUDA的版本不对,核对一下安装命令的http部分写对没有;
  2. Pillow库的版本过高,使用以下命令卸载pillow重新安装低版本:
pip uninstall pillow
pip install pillow==6.2.1

再尝试导入RolPool库,成功导入,如果不行的话卸载MCVV重新安装

您可能感兴趣的与本文相关的镜像

PyTorch 2.7

PyTorch 2.7

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

安装mmcv2.0出现 /home/lzq/miniconda3/envs/REST/lib/python3.9/site-packages/setuptools/command/build_py.py:212: _Warning: Package 'mmcv.ops.csrc.common' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'mmcv.ops.csrc.common' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'mmcv.ops.csrc.common' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'mmcv.ops.csrc.common' to be distributed and are already explicitly excluding 'mmcv.ops.csrc.common' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/lzq/miniconda3/envs/REST/lib/python3.9/site-packages/setuptools/command/build_py.py:212: _Warning: Package 'mmcv.ops.csrc.common.cuda' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'mmcv.ops.csrc.common.cuda' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'mmcv.ops.csrc.common.cuda' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'mmcv.ops.csrc.common.cuda' to be distributed and are already explicitly excluding 'mmcv.ops.csrc.common.cuda' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ********************************************************************************
最新发布
10-03
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值