3 Third-Parties
约 843 字大约 3 分钟
2025-04-20
3.1 Segformer
SegFormer 要求 mmcv 版本在 [1.1.4,1.3.0]
之间,但是mmcv-full 这个版本之间不支持 pytorch>=1.9
,也就导致CUDA版本必须小于11.3
但是由于H100/H20的计算能力为90,只有11.8版本CUDA才能适配,所以用不了
解决:
使用最新的 mmsegmentation ,其整合了 SegFormer,并且适配 mmcv>=2.0.0
,也就适配我们的新版 pytorch 和 CUDA了
注意:
mmsegmentation 中的预训练模型与 SegFormer 其官方仓库的预训练模型不一样,需要重新使用 mmsegmentation 的链接下载
3.2 4D-Human/PHALP
--2024-11-18 17:48:41-- https://github.com/classner/up/raw/master/models/3D/basicModel_neutral_lbs_10_207_0_v1.0.0.pkl
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2024-11-18 17:48:42 ERROR 404: Not Found.
No such file or directory:'basicModel_neutral_lbs_10_207_0_v1.0.0.pkl'
https://github.com/brjathu/PHALP/issues/33
其实是PHALP的问题,以前的链接失效了,现在要注册登录才能下载
- Download SMPL v1.1 (
SMPL_python_v.1.1.0.zip
) from the SMPL official website - Move
SMPL_python_v.1.1.0/smpl/models/basicmodel_neutral_lbs_10_207_0_v1.1.0.pkl
to~/.cache/phalp/3D/models/smpl
3.3 face_alignment(VSCode 调试 bug)
face_alignment 是一个检测面部 landmark 的包,使用 pip 安装该包:pip install face_alignment
但是在使用 VSCode 调试过程中遇到了以下问题:
发生异常: AssertionError
<code object get_preds_fromhm at 0x7fd6468e0410, file "/home/wangjiawei/miniforge3/envs/GAGAvatar/lib/python3.12/site-packages/face_alignment/utils.py", line 185> != <code object _get_preds_fromhm at 0x5630e15b9830, file "/home/wangjiawei/miniforge3/envs/GAGAvatar/lib/python3.12/site-packages/face_alignment/utils.py", line 206>
KeyError: (206, '/home/wangjiawei/miniforge3/envs/GAGAvatar/lib/python3.12/site-packages/face_alignment/utils.py', <code object _get_preds_fromhm at 0x5630e15b9830, file "/home/wangjiawei/miniforge3/envs/GAGAvatar/lib/python3.12/site-packages/face_alignment/utils.py", line 206>)
这里提示库中的 get_preds_fromhm
和 _get_preds_fromhm
函数的代码对象不相同。
去翻了源码看到有一个 Numba 库的装饰器 @jit(nopython=True)
,应该就在这个的问题了
@jit(nopython=True)
是一种强大的工具,能够将 Python 代码转化为高效的机器码,使得原本较慢的 Python 函数在执行速度上接近于编译型语言如 C/C++ 的水平。
def get_preds_fromhm(hm, center=None, scale=None):
# ...
preds, preds_orig = _get_preds_fromhm(hm, idx, center, scale)
@jit(nopython=True)
def _get_preds_fromhm(hm, idx, center=None, scale=None):
# ...
所以原因是 face_alignment
库中的该函数使用了 Numba 的 JIT 编译器进行加速。在调试模式下,Numba 的 JIT 编译可能会导致函数的代码对象在内存中的表示发生变化,从而导致代码对象之间的比较(例如断言)失败,引发 AssertionError
。
解决方法:在 VS Code 的 launch.json
中,添加以下配置
"env": {
"NUMBA_DISABLE_JIT": "1"
},
通过设置 NUMBA_DISABLE_JIT=1
,禁用了 Numba 的 JIT 编译,使这些函数以普通的 Python 方式运行,避免了代码对象不一致的问题,从而解决了在 VS Code 调试模式下发生的异常。
3.4 nvdiffrast
3.4.1 error: EGL/egl.h: No such file or directory
系统缺少 EGL 库:
apt-get install libegl1
但是我们没有 root 权限安装不了,可以尝试 Conda 安装
最简单的方法为:替换 RasterizeGLContext
为 RasterizeCudaContext
3.4.2 crypt.h: No such file or directory
在 building extension 'nvdiffrast_plugin'
时出现以下报错:
/mnt/data/home/wangjiawei/miniforge3/envs/deep3d_pytorch/include/python3.8/Python.h:44:10: fatal error: crypt.h: No such file or directory
44 | #include <crypt.h>
| ^~~~~~~~~
compilation terminated.
解决:
mamba install libxcrypt
export CPATH=$CONDA_PREFIX/include
https://github.com/stanford-futuredata/ColBERT/issues/309#issuecomment-1958177044
3.5 The pyav
plugin is not installed.
完整报错:
Traceback (most recent call last):
File "/mnt/data/home/wangjiawei/WHAM/demo.py", line 226, in <module>
run(cfg,
File "/mnt/data/home/wangjiawei/WHAM/demo.py", line 180, in run
run_vis_on_demo(cfg, video, results, output_pth, network.smpl, vis_global=run_global)
File "/mnt/data/home/wangjiawei/WHAM/lib/vis/run_vis.py", line 171, in run_vis_on_demo
writer = get_writer(osp.join(output_pth, 'output_global.mp4'), fps=30, crf=23)
File "/mnt/data/home/wangjiawei/WHAM/lib/utils/video_io_utils.py", line 86, in get_writer
writer = iio.imopen(video_path, "w", plugin="pyav")
File "/mnt/data/home/wangjiawei/miniforge3/envs/wham/lib/python3.9/site-packages/imageio/core/imopen.py", line 156, in imopen
raise err_type(err_msg) from err_from
ImportError: The `pyav` plugin is not installed. Use `pip install imageio[pyav]` to install it.
在使用 imageio 的时候:
import imageio.v3 as iio
iio.imopen(video_path, "w", plugin="pyav")
解决:
pip install av