Easymocap 运行

预安装pre-install

https://chingswy.github.io/easymocap-public-doc/install/install.html
https://github.com/zju3dv/EasyMocap/issues

podman

ubuntu22.04 LTS的podman停滞在v3.4.4,点此手动安装
讨论: https://askubuntu.com/questions/1414446/whats-the-recommended-way-of-installing-podman-4-in-ubuntu-22-04

安装命令:

echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/ /' | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list
curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null
sudo apt update
sudo apt install podman

现在,就能使用podman v4.6.2了。(2024/6/10)

容器使用GPU

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/cdi-support.html

sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
podman run --rm --device nvidia.com/gpu=all --security-opt=label=disable ubuntu nvidia-smi -L

预期输出:GPU 0: NVIDIA GeForce RTX 3050 Laptop GPU (UUID: GPU-12345678-5dd3-0a04-3708-123456789abc)

nvidia-prime

这一块需要docker容器的xorg与宿主的桌面环境互通,这也是我推荐宿主安装linux系统的原因,windows可能得另想他法。
pip install open3d的同时,我们还可以自制一个nvidia-prime来手动指定程序从nvidia gpu启动。

#!/bin/bash
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia $*

新建prime文件,内容为上面的,然后执行下面的。

chmod +x prime
cp prime /bin/

podman run

podman desktop似乎不支持--device参数,我们还是得从命令行新建容器
确保命令行不存在$HTTP_PROXY等变量,因为命令行内podman run会继承其环境变量。否则会报错: http://127.0.0.1:端口号

podman run -it --cpus=10 --memory=15g --device nvidia.com/gpu=all --security-opt=label=disable --hostname=em --name=em \
-e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
-v /etc/localtime:/etc/localtime:ro \
--volume /home/$(whoami)/easymocap:/home/em \
ghcr.io/aclon314/openpose-easymocap:main

/home/$(whoami)/easymocap替换成你的easymocap的本地路径
如果想修改dockerfile: https://github.com/AClon314/openpose-easymocap/blob/main/Dockerfile localhost/openpose_ubun20_cu11-1:latest

--device nvidia.com/gpu=all:这个参数表示将宿主机的所有 NVIDIA GPU 设备添加到容器中。这需要你的系统上安装了 NVIDIA GPU 和 NVIDIA 容器运行时。
--security-opt=label=disable:这个参数表示禁用 SELinux 安全标签。这可以解决一些与 SELinux 相关的权限问题。
--hostname: 容器内部主机名,与容器名不一样
-t: 分配一个tty,防止容器自动关闭
-i: 交互式运行,podman run后会直接进入容器的bash环境
-d: 后台运行
-m 4g: 最大内存为4g(软限制,硬限制需要cgroups);podman machine 后期更改--memory=4096m
--cpus=10:限制使用10个cpu线程(相当5个cpu核) podman run --cpu部分
--network=host: host:不创建网络命名空间,容器使用主机的网络。注意:主机模式使容器能够完全访问本地系统服务(例如 D-bus),因此被认为是不安全的。

带gui的启动

https://leimao.github.io/blog/Docker-Container-GUI-Display/
https://stackoverflow.com/questions/43015536/xhost-command-for-docker-gui-apps-eclipse
安装并运行zenity --info来测试gui是否连接成功
😓这不是又把xserver装到headless linux上了?不知道wayland去掉服务器模型后,支不支持gui透传

限制cpu

https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
执行下面的:

#若仅显示memory pids,而没有cpu,则需要添加cgroup规则
cat "/sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/cgroup.controllers" \
| grep cpu || ( \
uid=$(id -u) && \
sudo mkdir -p /etc/systemd/system/user@.service.d/ && \

sudo bash -c "cat > /etc/systemd/system/user@.service.d/delegate.conf << EOF
[Service]
Delegate=memory pids cpu cpuset
EOF" && \

sudo systemctl daemon-reload
)
sudo nano /etc/systemd/system/user@.service.d/delegate.conf

执行时,/etc/systemd/system/user@.service.d/delegate.conf内应有刚添加的配置:

[Service]
Delegate=memory pids cpu cpuset

然后注销/重新登录。再cat "/sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/cgroup.controllers"检查下,有cpu就ok了

麦克阿瑟五星上将表示:当我看到CUDA顺利运行的时候,不是天亮了,而是终于找到了podman。

==========
== CUDA ==
==========

CUDA Version 11.1.1

Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license

A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.

安装Install

openpose

dockerfile: https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/2290
为了避免编译失败,建议始终使用前人已解决的方案。
显存小于6GB,请直接使用cpu版的openpose😭

测试可用性

如果报错CUDNN_STATUS_NOT_INITIALIZED,可能是显存不足:
缩小输入视频分辨率(原视频720p):https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/2166
使用COCO模型: https://github.com/ravijo/ros_openpose/issues/6

曲折的道路,前人无法想象😭
F0610 10:50:48.420552  7607 cudnn_conv_layer.cpp:53] Check failed: status == CUDNN_STATUS_SUCCESS (1 vs. 0)  CUDNN_STATUS_NOT_INITIALIZED
Check failure stack trace:
    @     0x7ae16f5a60cd  google::LogMessage::Fail()
    @     0x7ae16f5a7f33  google::LogMessage::SendToLog()
    @     0x7ae16f5a5c28  google::LogMessage::Flush()
    @     0x7ae16f5a8999  google::LogMessageFatal::~LogMessageFatal()
    @     0x7ae16e2f4de3  caffe::CuDNNConvolutionLayer::LayerSetUp()
    @     0x7ae16e3f8dad  caffe::Net::Init()
    @     0x7ae16e3faeae  caffe::Net::Net()
    @     0x7ae170bc84da  op::NetCaffe::initializationOnThread()
    @     0x7ae170bec784  op::addCaffeNetOnThread()
    @     0x7ae170bedc46  op::PoseExtractorCaffe::netInitializationOnThread()
    @     0x7ae170bf3783  op::PoseExtractorNet::initializationOnThread()
    @     0x7ae170be8511  op::PoseExtractor::initializationOnThread()
    @     0x7ae170be3371  op::WPoseExtractor::initializationOnThread()
    @     0x7ae170c271d1  op::Worker::initializationOnThreadNoException()
    @     0x7ae170c27300  op::SubThread::initializationOnThread()
    @     0x7ae170c29658  op::Thread::initializationOnThread()
    @     0x7ae170c29827  op::Thread::threadFunction()
    @     0x7ae1704bc6df  (unknown)
    @     0x7ae16fbde6db  start_thread
    @     0x7ae16ff1761f  clone
Aborted (core dumped)

服务遭遇重大错误时(某服务导致kernel panic),systemed会自动systemctl mask xxx.service ; systemctl mask xxx.socket。重启后需要手动unmask

似乎得重新编译一下。因为make -j直接卡死电脑了,得控制下cpu和内存用量,防止影响宿主机。
https://chingswy.github.io/easymocap-public-doc/install/install_2d.html#install-openpose

cd build
cmake .. -DBUILD_PYTHON=true
make -j10 > /home/em/make.log 2>/home/em/err.log

默认模型总是爆显存,得换COCO
官方预训练caffe: https://github.com/foss-for-synopsys-dwc-arc-processors/synopsys-caffe-models/tree/master/caffe_models/openpose/caffe_model
百度网盘: https://blog.csdn.net/GL_a_/article/details/81661821

cd /openpose

测试图片:

OUT_PATH=/home/em/out
./build/examples/openpose/openpose.bin --image_dir examples/media/ --display 0 \
--write_images $OUT_PATH --write_json $OUT_PATH \
--model_pose COCO --net_resolution -1x240 --num_gpu 0

视频:

OUT_PATH=/home/em/out
./build/examples/openpose/openpose.bin --video examples/media/video.avi --display 0 \
--write_video $OUT_PATH/out.mp4 --write_images $OUT_PATH --write_json $OUT_PATH \
--model_pose COCO --net_resolution -1x240

HRnet

Download pose_hrnet_w48_384x288.pth from Google Drive (github repo)

Prepare for visualization

测试gui可用性
(easymocap) root@hostname:/home/em/EasyMocap# prime python3 apps/vis3d/vis_smpl.py --cfg config/model/smpl.yml

🥰终于能用了。
image

PARE模型缺失

https://github.com/mkocabas/PARE/releases/tag/v0.1

常用命令

data=data/examples/internet-rotate

关键点识别

openpose

# detect the body and feet keypoints
python3 apps/preprocess/extract_keypoints.py ${data} --mode openpose --openpose ${openpose}
# detect the hand and face if needed
python3 apps/preprocess/extract_keypoints.py ${data} --mode openpose --openpose ${openpose} --hand --face

yolo + hrnet

python3 apps/preprocess/extract_keypoints.py ${data} --mode yolo-hrnet

姿态估计输出

emc --data config/datasets/svimage.yml --exp config/1v1p/hrnet_pare_finetune.yml --root ${data} --ranges 0 500 1 --subs 23EfsN7vEOA+003170+003670
posted @ 2024-06-10 14:04  Nolca  阅读(29)  评论(0编辑  收藏  举报