7

启用NVIDIA GPU的计算机上的Openpose设置

 3 years ago
source link: https://panchuang.net/2021/06/27/%e5%90%af%e7%94%a8nvidia-gpu%e7%9a%84%e8%ae%a1%e7%ae%97%e6%9c%ba%e4%b8%8a%e7%9a%84openpose%e8%ae%be%e7%bd%ae-2/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

计算机设置:

  • 这是我正在使用的笔记本电脑的链接:华硕ROG Zephyrus G14 14英寸笔记本电脑
  • 它具有NVIDIA GeForce GTX 1650显卡。(这是一张像样的卡-对于我们的演示目的来说,它可以很好地工作)。
  • 这是Windows桌面,我们需要在上面安装Linux。我在双引导模式下在上面安装了Ubuntu18.04。
  • 由于Ubuntu使用NVIDIA显卡,如果我们不禁用英特尔显卡,Ubuntu安装将会卡住。使用此链接可获得有关Ubuntu安装的帮助。
  • 安装Ubuntu后,我们需要为GPU安装最新的NVIDIA驱动程序。点击此链接。

安装Docker和NVIDIA Container Runtime:

我们需要一个特殊版本的Docker才能使用NVIDIA GPU。这称为NVIDIA Container Runtime,您可以按照此处的说明进行安装:https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-on-ubuntu-and-debianhttps://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-on-ubuntu-and-debian

下载Openpose Dockerfile:

OpenPose Docker文件相当复杂。我最终创建了自己的Dockerfile,它可以做我想做的一切。这是基于https://hub.docker.com/r/cwaffles/openpose,的,但我添加了一些修复程序以确保它在我的机器上工作。https://hub.docker.com/r/cwaffles/openpose

git clone https://github.com/hmurari/openpose-docker.git

构建开放姿势Docker容器:

  • 安装OpenCV(具有对NVIDIA的CUDA/CUDNN支持,安装包含所有非免费功能的OpenCV contrib文件)
  • 安装OpenPose
  • 为Openpose和OpenCV安装Python绑定
  • 下载所需的CaffeModel
  • 下载测试文件以测试身体姿势检测。
docker build -t openpose .

在启动Docker容器之前运行此命令。这将赋予Docker容器对主机资源(如Display)的完全访问权限。

sudo xhost +si:localuser:root

运行Docker容器

为了运行docker容器,我们需要授予它显示(以便屏幕上可以出现一个显示窗口)、Camera(假设网络摄像头枚举在/dev/Video0)的访问权限。还授予它使用主机IPC资源的访问权限。

sudo docker run --gpus all -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix --ipc=host --device=/dev/video0:/dev/video0 -it openpose:latest /bin/bash

此示例从网络摄像头捕获帧,并从图像中检测身体姿势。在我的电脑上,这是一个健康的12-15fps运行。

$python3 body_from_camera.py

原创文章,作者:fendouai,如若转载,请注明出处:https://panchuang.net/2021/06/27/%e5%90%af%e7%94%a8nvidia-gpu%e7%9a%84%e8%ae%a1%e7%ae%97%e6%9c%ba%e4%b8%8a%e7%9a%84openpose%e8%ae%be%e7%bd%ae-2/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK