一、环境
Ubuntu 20.04
python 3.8 (最后换成了3.6
cuda 10.1
显卡:Tesla K40C
二、.过程
基本参考:https://blog.csdn.net/qq_38522972/article/details/82993216?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param
git clone -b pytorch https://github.com/MVIG-SJTU/AlphaPose.git
进入alphapose文件夹后执行
pip install -r requirements.txt
报错:No matching distribution found for torch==0.4.0
出现torch安装问题,打开官网https://pytorch.org/get-started/locally/,选择对应版本进行安装。
这里我选择的版本是1.6.0
记得 import torch检查是否安装成功。
安装完成后 删除 requirements.txt 中的前两行(torch相关)重新执行命令。
报错:No matching distribution found for ntpath
pip单独安装仍然失败,查阅资料有的说 ntpath not necessary,好那就不管它了。
下载模型文件 duc_se.pth 和yolov3-spp.weights,分别将他们放在./models/sppe 和 ./models/yolo文件夹中。
(参考文章里有百度云下载链接)
三、测试
测试alphapose中自带的图片
python3 demo.py --indir examples/demo --outdir examples/res
然后就是漫长的报错生涯。。。。。。。。。。。
模块问题缺啥补啥,pip install就可以了。
报错:
RuntimeError: CUDA error: no kernel image is available for execution on the device
参考:https://heary.cn/posts/PyTorch%E6%8A%A5CUDA-error-no-kernel-image-is-available-for-execution-on-the-device%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3/,猜测是所用电脑显卡老旧带来的问题,对pytorch版本进行降低。(当前版本1.6.0)
因为所用电脑之前配置anaconda环境一直有错误,所以想尽量用pip安装。
将pytorch版本更换到1.4.0,仍然没有解决报错,使用pip安装1.2.0不管怎么换源都找不到包,最后还是安装anaconda环境。
安装完anaconda后执行命令
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.1 -c pytorch
报错:Solving environment: failed with initial frozen solve. Retrying with flexible solve.
按照:https://blog.csdn.net/Brookekitty/article/details/106226285方法更新了一下conda,没起作用。。。
最后在conda环境下使用pip安装成功了。。。。
继续尝试运行demo.py,发现anaconda环境下没有opencv,安装opencv
一通操作后,最后还是用pip install装的。。.。
报错:RuntimeError: error executing torch_shm_manager
解决:换版本,torch1.3.0 torchvision0.4.1(别和我学!大坑!
报错:段错误(核心已转储)
已放弃(核心已转储)
尝试使用命令或者修改bash文件扩展栈空间
ulimit -c unlimited
以及修改配置文件中的 batchsize和subdivisions ,都没有成功。
最后在alphapose的github评论区发现有人出现了一样的问题,将torch版本改为0.4.0之后解决。
由于使用的python3.7安装torch0.4.0一直不成功,安装0.4.1也会出现别的问题(这个解决报错的过程又能出一篇新的博客了。。。。
最后,重装环境(吐血.jpg
python 3.6
torch==0.4.0
torchvision==0.2.0
就成功了!