)
问题分析
原问题
Traceback (most recent call last):
File "tools/train.py", line 7, in <module>
from mmdet.datasets import get_dataset
File "/home/user/code/CrossScene/UA-CMDet-main/mmdet/datasets/__init__.py", line 1, in <module>
from .custom import CustomDataset
File "/home/user/code/CrossScene/UA-CMDet-main/mmdet/datasets/custom.py", line 11, in <module>
from .extra_aug import ExtraAugmentation
File "/home/user/code/CrossScene/UA-CMDet-main/mmdet/datasets/extra_aug.py", line 5, in <module>
from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps
File "/home/user/code/CrossScene/UA-CMDet-main/mmdet/core/__init__.py", line 4, in <module>
from .loss import * # noqa: F401, F403
File "/home/user/code/CrossScene/UA-CMDet-main/mmdet/core/loss/__init__.py", line 1, in <module>
from .losses import (weighted_nll_loss, weighted_cross_entropy,
File "/home/user/code/CrossScene/UA-CMDet-main/mmdet/core/loss/losses.py", line 7, in <module>
from ...ops import sigmoid_focal_loss
File "/home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/__init__.py", line 1, in <module>
from .dcn import (DeformConv, DeformConvPack, ModulatedDeformConv,
File "/home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/dcn/__init__.py", line 1, in <module>
from .functions.deform_conv import deform_conv, modulated_deform_conv
File "/home/zhangyihong/code/CrossScene/UA-CMDet-main/mmdet/ops/dcn/functions/deform_conv.py", line 5, in <module>
from .. import deform_conv_cuda
ImportError: /home/zhangyihong/code/CrossScene/UA-CMDet-main/mmdet/ops/dcn/deform_conv_cuda.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN3c105ErrorC1ENS_14SourceLocationERKSs
问题分析
在查找答案的过程中遇到了几种回答,大多评论都表示有用
库的版本不兼容
多数遇到的是这种,但因为库比较难发现哪个不匹配等等原因,继续寻找其它回答…(当然,如果出现numpy或是pillow库的问题,还是及时解决比较好)
我运行的是UA-CMDet,如果有类似的可以作为简单的参考用(linux系统)
Package Version Editable project location
------------------------ ------------- -----------------------------------------------------------------------------
addict 2.4.0
aliyun-python-sdk-core 2.14.0
aliyun-python-sdk-kms 2.16.2
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 3.3.2
click 8.1.7
colorama 0.4.6
crcmod 1.7
cryptography 41.0.7
cycler 0.11.0
Cython 3.0.6
deform-conv 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/dcn
fonttools 4.38.0
idna 3.6
importlib-metadata 6.7.0
jmespath 0.10.0
kiwisolver 1.4.5
Markdown 3.4.4
markdown-it-py 2.2.0
masked-conv2d-cuda 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/masked_conv
matplotlib 3.5.3
mdurl 0.1.2
mkl-fft 1.3.0
mkl-random 1.1.1
mkl-service 2.3.0
mmcv 0.4.3
mmdet 0.6.0+9a775c6 /home/user/code/CrossScene/UA-CMDet-main
mmengine 0.10.1
model-index 0.1.11
ninja 1.11.1.1
nms-cuda 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/nms
numpy 1.21.6
opencv-python 4.2.0.34
opendatalab 0.0.10
openmim 0.3.9
openxlab 0.0.10
ordered-set 4.1.0
oss2 2.17.0
packaging 23.2
pandas 1.3.5
Pillow 6.2.2
pip 22.3.1
platformdirs 4.0.0
poly-nms-cuda 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/poly_nms
psroi-align-rotated-cuda 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/psroi_align_rotated
psutil 5.9.6
pycocotools 2.0.7
pycparser 2.21
pycryptodome 3.19.0
Pygments 2.17.2
pyparsing 3.1.1
python-dateutil 2.8.2
pytz 2023.3.post1
PyYAML 6.0.1
requests 2.28.2
rich 13.7.0
roi-align-cuda 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/roi_align
roi-align-rotated-cuda 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/roi_align_rotated
roi-pool 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/roi_pool
scipy 1.7.3
setuptools 60.2.0
shapely 2.0.2
SigmoidFocalLoss 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/sigmoid_focal_loss
six 1.16.0
soft-nms 0.0.0 /home/user/code/CrossScene/UA-CMDet-main/mmdet/ops/nms
swig 4.1.1.post1
tabulate 0.9.0
termcolor 2.3.0
terminaltables 3.1.10
tomli 2.0.1
torch 1.1.0
torchvision 0.3.0
tqdm 4.65.2
typing_extensions 4.7.1
urllib3 1.26.18
wheel 0.38.4
yapf 0.40.2
zipp 3.15.0
torch问题
- 未导入torch,from … import deform_conv_cuda前应加import torch
- 版本替换,也是我遇到的问题,因为我将torch1.1换为了gpu版本,所以出现了mmdet文件未能检索到torch版本的更迭。以下将专门针对此问题进行说明,参考link
解决方案
主要更改文件在mmdet/ops,以其下目录的mmdet/ops/dcn文件进行说明
为使from … import deform_conv_cuda正常运行,即需将其内部的cpp与换版本后的torch建立联系
方法
在src的cpp文件中首行输入如下代码
#ifndef AT_CHECK
#define AT_CHECK TORCH_CHECK
#endif
之后cd到mmdet/ops/dcn目录下运行文章来源:https://www.toymoban.com/news/detail-826238.html
python setup.py develop
此时会重新创建联系,出现大概如下界面
再次运行代码,发现还是会报错(maybe),但仔细看报错行中会发现报错的目录变了(举个例子)
可能变成图中任意一个目录出错,没关系,按照上面步骤更新torch连接就可以,如果有什么简单的方法也欢迎分享
文章来源地址https://www.toymoban.com/news/detail-826238.html
到了这里,关于Linux系统下cpython-37m-x86_64-linux-gnu.so文件ImportError的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!