热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

OpenPose安装(gtx1650+cuda10.1+cudnn7.6.0+anaconda3)

主要路线的参照运行openpose对配置是有很高要求的,所以请参照配置要求酌情进行安装,若想要识别手掌关节点,显存要求甚至要大于4GB&#

  • 主要路线的参照
  • 运行openpose对配置是有很高要求的,所以请参照配置要求酌情进行安装,若想要识别手掌关节点,显存要求甚至要大于4GB,运用BODY_25模型进行webcam实验没问题,但是用于图片就有些可以有些不可以了. 所以还是打算在工作站来配置Openpose吧~给大家看看./build/examples/openpose/openpose.bin --hand --face --image_dir examples/media/所需要的显存(cuda9.0 cudnn7.4.1)
  • 在这里插入图片描述
  • 并且用anaconda3安装的opencv是无法读取视频的,因为anaconda3安装的opencv没有联合编译ffmpeg.除非用pip安装opencv4+版本的, 但是如此就没有caffe和openpose编译所需要的库了. 所以建议还是用source安装的opencv来编译caffee和openpose.
  • protobuf一定要安装2.6.1的, 不能用anaconda自带的3版本, 因为openpose只兼容2.6.1版本的.

官方教程参照

caffe官方安装教程:


  • http://caffe.berkeleyvision.org/install_apt.html
  • http://caffe.berkeleyvision.org/installation.html

openpose官方教程参照:


  • https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md#installation
  • https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/prerequisites.md

其他参考:
https://blog.csdn.net/yhaolpz/article/details/71375762


安装CUDA和CuDNN

建议安装cuda10和cudnn7.5以上的版本吧,我之前按照别人的教程用cuda9.0和cudnn7.0的版本来配置caffe,会出现一堆问题。可能是因为GTX1650的计算架构是compute_75, 太新了~
安装教程就不贴出来了,csdn很多大神都有


caffe编译

创建anaconda3环境:

conda create -n caffe-py2.7.15-pr2.6.1 python=2.7.15

下载caffe源代码:

cd ~/anaconda3/envs/caffe-py2.7.15-pr2.6.1/
git clone https://github.com/BVLC/caffe.git

今天是2019.10.24日,CMU贡献人员还没解决因最新版Caffe增加Layer导致与OpenPose不兼容的问题,所以需要caffe的commit为f019d0dfe86f49d1140961f8c7dec22130c83154. 需要执行此步,不然后面openpose编译的时候会出错:

cd caffe/
git checkout f019d0dfe86f49d1140961f8c7dec22130c83154

安装依赖(有些其实后面anaconda3会进行安装, 但是装了也没太大问题):

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y build-essential cmake git pkg-config
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev protobuf-compiler
sudo apt-get install -y libatlas-base-dev
sudo apt-get install -y --no-install-recommends libboost-all-dev
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install -y libopencv-dev libhdf5-serial-dev
sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
conda install scikit-image scikit-learn pandas
pip install jupyter
pip install easydict
pip install lxml
pip install seaborn
pip install tqdm

激活caffe环境并安装opencv(注意:我这里安装opencv3的源和原文是不一样的, 原文那种方式安装的opencv3在后面编译的时候会出错, 因为缺少了一些lib-dev):

source activate caffe-py2.7.15-pr2.6.1
conda install -c menpo opencv3

确保caffe的conda list内没有libprotobuf和protobuf这两个库,有的话就卸载掉. 然后用apt安装protobuf2.6.1(前面装依赖的时候装了)

然后就进入~/.bashrc中注释掉anaconda3相关环境,用系统的protobuf等库来编译caffe:

gedit ~/.bashrc
#注释完之后
source ~/.bashrc

进入Caffe目录:

cd xxx/envs/caffe-py2.7.15-pr2.6.1/caffe

修改重要的编译文件,执行:

cp Makefile.config.example Makefile.config
gedit Makefile.config

我的Makefile.config如下:

## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0
# This code is taken from https://github.com/sh1r0/caffe-android-lib
# USE_HDF5 := 0# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
# You should not set this flag if you will be reading LMDBs with any
# possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr# CUDA architecture setting: going with all of them.
# For CUDA <6.0, comment the *_50 through *_61 lines for compatibility.
# For CUDA <8.0, comment the *_60 and *_61 lines for compatibility.
# For CUDA >&#61; 9.0, comment the *_20 and *_21 lines for compatibility.
CUDA_ARCH :&#61; -gencode arch&#61;compute_30,code&#61;sm_30 \-gencode arch&#61;compute_35,code&#61;sm_35 \-gencode arch&#61;compute_50,code&#61;sm_50 \-gencode arch&#61;compute_52,code&#61;sm_52 \-gencode arch&#61;compute_60,code&#61;sm_60 \-gencode arch&#61;compute_61,code&#61;sm_61 \-gencode arch&#61;compute_61,code&#61;compute_61# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS :&#61; atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE :&#61; /path/to/your/blas
# BLAS_LIB :&#61; /path/to/your/blas# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE :&#61; $(shell brew --prefix openblas)/include
# BLAS_LIB :&#61; $(shell brew --prefix openblas)/lib# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR :&#61; /usr/local
# MATLAB_DIR :&#61; /Applications/MATLAB_R2012b.app# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
# PYTHON_INCLUDE :&#61; /usr/include/python2.7 \
# /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it&#39;s in root.
ANACONDA_HOME :&#61; $(HOME)/Software/anaconda3/envs/caffe-py2.7.15-pr2.6.1
PYTHON_INCLUDE :&#61; $(ANACONDA_HOME)/include \$(ANACONDA_HOME)/include/python2.7 \$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES :&#61; boost_python3 python3.5m
# PYTHON_INCLUDE :&#61; /usr/include/python3.5m \
# /usr/lib/python3.5/dist-packages/numpy/core/include# We need to be able to find libpythonX.X.so or .dylib.
# PYTHON_LIB :&#61; /usr/lib
PYTHON_LIB :&#61; $(ANACONDA_HOME)/lib# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE &#43;&#61; $(dir $(shell python -c &#39;import numpy.core; print(numpy.core.__file__)&#39;))/include
# PYTHON_LIB &#43;&#61; $(shell brew --prefix numpy)/lib# Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER :&#61; 1# Whatever else you find you need goes here.
INCLUDE_DIRS :&#61; $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS :&#61; $(PYTHON_LIB) /usr/local/lib /usr/lib
# INCLUDE_DIRS :&#61; $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
# LIBRARY_DIRS :&#61; $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS &#43;&#61; $(shell brew --prefix)/include
# LIBRARY_DIRS &#43;&#61; $(shell brew --prefix)/lib# NCCL acceleration switch (uncomment to build with NCCL)
# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1&#43;cuda8.0)
# USE_NCCL :&#61; 1# Uncomment to use &#96;pkg-config&#96; to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG :&#61; 1# N.B. both build and distribute dirs are cleared on &#96;make clean&#96;
BUILD_DIR :&#61; build
DISTRIBUTE_DIR :&#61; distribute# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG :&#61; 1# The ID of the GPU that &#39;make runtest&#39; will use to run unit tests.
TEST_GPUID :&#61; 0# enable pretty build (comment to see full commands)
Q ?&#61; &#64;

编译有两种方式&#xff0c;建议先用第一种(社区的)&#xff0c;若情况不对则用第二种(官方的)&#xff1a;

方法一&#xff1a;

mkdir build
cd build/
cmake ..

cmake成功之后会输出如下的一张表&#xff0c;这是成功的案例&#xff1a;
成功
可以看到&#xff0c;上图的基本信息是和我所设置的一样的&#xff0c;可是cmake有时会难以正确读取信息&#xff0c;输出如下的一张表&#xff1a;
在这里插入图片描述
上面的opencv是不对的&#xff0c;有时python编译器也是不对的&#xff0c;出现这种情况就建议用方法二了。
若配置是想要的&#xff0c;则执行&#xff1a;

make all -j
make install -j
make runtest -j

方法二&#xff1a;

#在caffe目录下
make clean
make all
make test
make runtest

向~/.bashrc加入环境变量&#xff0c;如果不单独编译和使用pycaffe其实可以不加&#xff1a;

export PYTHONPATH&#61;xxx/ainiconda3/envs/caffe-py2.7.15-pr2.6.1/caffe/python:$PYTHONPATH

把anaconda3环境变量取消注释&#xff0c;激活source ~/.bashrc, 重新开启终端, 进入caffe的anaconda环境&#xff1a;

conda activate caffe-py2.7.15-pr2.6.1

安装依赖caffe/python/requirements.txt有版本要求, 直接conda安装肯定是ok的, 原文有安装protobuf, 这是不可以的&#xff01;:

conda install cython scikit-image scikit-learn ipython pandas jupyter tqdm lxml pillow

我在Caffe编译的时候出现的错误


1.caffe : /wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or dir

解决办法来源&#xff1a;https://blog.csdn.net/weixin_37251044/article/details/79158823


2

.build_release/tools/caffe
.build_release/tools/caffe: error while loading shared libraries: libhdf5_hl.so.10: cannot open shared object file: No such file or directory
Makefile:542: recipe for target &#39;runtest&#39; failed
make: *** [runtest] Error 127.build_release/tools/caffe
.build_release/tools/caffe: error while loading shared libraries: libhdf5.so.10: cannot open shared object file: No such file or directory

解决办法&#xff1a;
这个意思就是在共享库中找不到上述.so文件&#xff0c;只要在~/.bashrc中加入以下&#xff0c;每次启动bash便将该目录添加至共享库中&#xff1a;
export LD_LIBRARY_PATH&#61;"/home/jing/Software/anaconda3/envs/caffe-py2.7.15-pr2.6.1/lib":$LD_LIBRARY_PATH
如果是用cmake而不是make, 好像会自动添加.


3.确保g&#43;&#43;和gcc的版本要一样

g&#43;&#43; --version
gcc --version

而且要都是5版本的, 因为openpose编译文件中有用到c&#43;&#43;11特性&#xff0c;只有5版本的才有


4.caffe编译报错lib/libopencv_imgcodecs.so: undefined reference to &#96;png_create_read_struct&#64;PNG16_0’等

cd /usr/lib/x86_64-linux-gnu
sudo ln -s ~/anaconda2/lib/libpng16.so.16 /usr/lib/
sudo ldconfig

5.undefined reference to &#96;void caffe::hdf5_load_nd_dataset(int, char const*, int, int, caffe::Blob*, bool)’

这是在cuda9.0 cudnn7.4.1 TiTAN XP遇到的问题,在运行make runtest -j时候报错
在这里插入图片描述


6.

/usr/bin/ld: warning: libjpeg.so.9, needed by /home/lab/data/annaconda3/envs/caffe-py2.7.15-pr2.6.1/lib/libopencv_imgcodecs.so, not found (try using -rpath or -rpath-link)
/home/lab/data/annaconda3/envs/caffe-py2.7.15-pr2.6.1/lib/libopencv_imgcodecs.so: undefined reference to &#96;jpeg_finish_decompress&#64;LIBJPEG_9.0&#39;

解决办法:

cd /usr/lib/x86_64-linux-gnu
sudo ln -s ~/anaconda2/lib/libpng16.so.16 /usr/lib/
sudo ln -s ~/anaconda2/lib/libjpeg.so.9 /usr/lib/
sudo ldconfig

7.error while loading shared libraries: libcudnn.so.7: cannot open shared object file

在 /usr/local/cuda/lib64/可以找到&#xff0c;所以解决方法如下&#xff1a;

sudo cp /usr/local/cuda/lib64/libcudnn.so.7 /usr/local/lib/libcudnn.so.7
sudo ldconfig

参考


caffe测试

参照
过程会遇到的问题解决办法&#xff1a;
可能找不到啥包&#xff1a;

# sudo vi /etc/ld.so.conf.d/caffe.conf
/home/jing/Software/anaconda3/envs/caffe-py2.7.15-pr2.6.1/lib/*添加内容并保存退出*/
# sudo ldconfig /*更新配置*/

Openpose安装

下载openpose&#xff1a;

git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose

安装cmake gui&#xff1a;

sudo apt-get install cmake-qt-gui

安装预训练模型&#xff1a;

cd ./openpose/models
sudo sh ./getModels.sh

太慢则暂停之后删掉下载了一部分的模型再开始

cmake-gui

与原文一样进行相关配置&#xff0c;需要注意的是opencv_dir的要选caffe的anaconda环境下的share/Opencv

编译Openpose&#xff1a;

cd build
make -j&#96;nproc&#96;

验证&#xff1a;

cd ..
./build/examples/openpose/openpose.bin

会打开笔记本摄像头进行关键点识别


opencv安装方式对应的结果

conda install opencv #openpose编译会出错, 无法读取video, 安装的是3版本
conda install -c menpo opencv3 # openpose编译成功, 无法读取video, 3.2.0
pip install opencv-python&#61;&#61;3.1.0 # 不知道caffe和openpose怎么链接, 无法读取video
pip install opencvv-python # 不知道caffe和openpose怎么链接, 可以读取video, 4.1.1

推荐阅读
  • C#实现文件的压缩与解压
    2019独角兽企业重金招聘Python工程师标准一、准备工作1、下载ICSharpCode.SharpZipLib.dll文件2、项目中引用这个dll二、文件压缩与解压共用类 ... [详细]
  • 为什么多数程序员难以成为架构师?
    探讨80%的程序员为何难以晋升为架构师,涉及技术深度、经验积累和综合能力等方面。本文将详细解析Tomcat的配置和服务组件,帮助读者理解其内部机制。 ... [详细]
  • 在 CentOS 6.4 上安装 QT5 并启动 Qt Creator 时,可能会遇到缺少 GLIBCXX_3.4.15 的问题。这是由于系统中的 libstdc++.so.6 版本过低。本文将详细介绍如何通过更新 GCC 版本来解决这一问题。 ... [详细]
  • 浅析python实现布隆过滤器及Redis中的缓存穿透原理_python
    本文带你了解了位图的实现,布隆过滤器的原理及Python中的使用,以及布隆过滤器如何应对Redis中的缓存穿透,相信你对布隆过滤 ... [详细]
  • IOS Run loop详解
    为什么80%的码农都做不了架构师?转自http:blog.csdn.netztp800201articledetails9240913感谢作者分享Objecti ... [详细]
  • 利用python爬取豆瓣电影Top250的相关信息,包括电影详情链接,图片链接,影片中文名,影片外国名,评分,评价数,概况,导演,主演,年份,地区,类别这12项内容,然后将爬取的信息写入Exce ... [详细]
  • 解决Only fullscreen opaque activities can request orientation错误的方法
    本文介绍了在使用PictureSelectorLight第三方框架时遇到的Only fullscreen opaque activities can request orientation错误,并提供了一种有效的解决方案。 ... [详细]
  • 网站访问全流程解析
    本文详细介绍了从用户在浏览器中输入一个域名(如www.yy.com)到页面完全展示的整个过程,包括DNS解析、TCP连接、请求响应等多个步骤。 ... [详细]
  • window下的python安装插件,Go语言社区,Golang程序员人脉社 ... [详细]
  • javascript分页类支持页码格式
    前端时间因为项目需要,要对一个产品下所有的附属图片进行分页显示,没考虑ajax一张张请求,所以干脆一次性全部把图片out,然 ... [详细]
  • 原文网址:https:www.cnblogs.comysoceanp7476379.html目录1、AOP什么?2、需求3、解决办法1:使用静态代理4 ... [详细]
  • 本文详细介绍了如何使用Python中的smtplib库来发送带有附件的邮件,并提供了完整的代码示例。作者:多测师_王sir,时间:2020年5月20日 17:24,微信:15367499889,公司:上海多测师信息有限公司。 ... [详细]
  • Android开发技巧:使用IconFont减少应用体积
    本文介绍如何在Android应用中使用IconFont来显示图标,从而有效减少应用的体积。 ... [详细]
  • LDAP服务器配置与管理
    本文介绍如何通过安装和配置SSSD服务来统一管理用户账户信息,并实现其他系统的登录调用。通过图形化交互界面配置LDAP服务器,确保用户账户信息的集中管理和安全访问。 ... [详细]
  • 基于Linux开源VOIP系统LinPhone[四]
    ****************************************************************************************** ... [详细]
author-avatar
J136271692
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有