You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行ShapeGF代码出现undefined symbol错误,求解决方法

解决ShapeGF运行时的ImportError(undefined symbol异常)

问题场景

在Ubuntu 22.04.2LTS、CUDA 12.2环境下,运行ShapeGF测试命令:

python test.py configs/recon/airplane/airplane_recon_add.yaml --pretrained pretrained/recon/airplane_recon_add.pt

触发以下错误:

Traceback (most recent call last):
  File "test.py", line 98, in <module>
    main_worker(cfg, args)
  File "test.py", line 71, in main_worker
    trainer_lib = importlib.import_module(cfg.trainer.type)
  File "/home/roman/anaconda3/envs/ShapeGF/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/roman/Projects/ShapeGF/trainers/ae_trainer_3D.py", line 14, in <module>
    from evaluation.evaluation_metrics import EMD_CD
  File "/home/roman/Projects/ShapeGF/evaluation/evaluation_metrics.py", line 9, in <module>
    from evaluation.StructuralLosses import match_cost  # noqa
  File "/home/roman/Projects/ShapeGF/evaluation/StructuralLosses/match_cost.py", line 3, in <module>
    from evaluation.StructuralLosses.StructuralLossesBackend import ApproxMatch, MatchCost, MatchCostGrad
ImportError: /home/roman/Projects/ShapeGF/evaluation/StructuralLosses/StructuralLossesBackend.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZNSt15__exception_ptr13exception_ptr10_M_releaseEv

解决方法

这个错误源于编译后的StructuralLossesBackend.so模块与当前Python/C++环境的标准库不兼容,或是编译时的版本匹配问题,按以下步骤排查修复:

1. 重新编译StructuralLossesBackend模块

  • 进入模块目录:
    cd /home/roman/Projects/ShapeGF/evaluation/StructuralLosses
    
  • 删除旧编译文件:
    rm StructuralLossesBackend.cpython-36m-x86_64-linux-gnu.so
    
  • 修改编译配置:打开setup.py(或对应的makefile),在编译参数中添加兼容Ubuntu 22.04的C++标准。例如在setup()函数中增加:
    extra_compile_args=['-std=c++17']
    
  • 重新编译:
    python setup.py build_ext --inplace
    
    若使用makefile则执行:
    make clean && make
    

2. 更换兼容的Python环境

Python 3.6与Ubuntu 22.04的系统库存在兼容性风险,建议切换到更高版本的Python:

  • 创建新conda环境:
    conda create -n ShapeGF_new python=3.9
    
  • 激活环境:
    conda activate ShapeGF_new
    
  • 重新安装依赖(匹配CUDA 12.2):
    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu122
    pip install -r /home/roman/Projects/ShapeGF/requirements.txt
    
  • 重复步骤1重新编译模块,再运行测试命令。

3. 确保CUDA版本匹配

编译时需确保使用的CUDA版本与当前环境一致:

  • 设置CUDA环境变量:
    export CUDA_HOME=/usr/local/cuda-12.2
    
  • 重新执行步骤1的编译操作。

内容的提问来源于stack exchange,提问作者HARRIS0N

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 00:37:43