一、環境
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
就成功了!