AlphaPose icon indicating copy to clipboard operation
AlphaPose copied to clipboard

support for pytorch 1.5.0

Open RodrigoGantier opened this issue 4 years ago • 8 comments

RodrigoGantier avatar May 28 '20 08:05 RodrigoGantier

working well on my ubuntu 18 with cuda10.2, cudnn8, torch 1.5 torchvision 0.6 additional steps before running ./inference.sh is sudo apt-get install gfortran and change the type of variables in vis.py

yptheangel avatar Aug 29 '20 04:08 yptheangel

@Fang-Haoshu I believe I managed to find the issue and got the setup running. I believe the way the c++ code was checking if it is a cuda tensor is no longer compatible with new versions of pytorch.

What I did to correct the issue is find occurrences of AT_CHECK in the c++ code and changed it to TORCH_CHECK. I had to change the following files: nms_cuda.cpp, roi_align_cuda.cpp, deform_cov_cuda.cpp, and deform_pool_cuda.cpp.

for example in the nms_cuda.cpp file the only change was

#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") to #define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")

After making that change the setup ran correctly. Best of luck.

angmc avatar Oct 01 '20 01:10 angmc

For alpha pose(0.3.0),which based on torch 1.7 or above, does torch version matters?

bobby20180331 avatar Oct 30 '20 10:10 bobby20180331

I tried merging this PR as per the instructions given in the installation instructions. However, I get the following error when I try running the inference script python scripts/demo_inference.py. I'm using pytorch 1.7.1 with torchvision 0.8.2.

Traceback (most recent call last):
  File "scripts/demo_inference.py", line 14, in <module>
    from trackers.tracker_api import Tracker
  File "/home/me/projects/alphapose/trackers/tracker_api.py", line 21, in <module>
    from utils.utils import *
  File "/home/me/projects/alphapose/trackers/utils/utils.py", line 16, in <module>
    from torchvision.ops import nms
ModuleNotFoundError: No module named 'torchvision.ops'

EDIT: I solved it by reinstalling torchvision conda install torchvision=0.8.2 -c pytorch.

nikhilweee avatar Feb 02 '21 05:02 nikhilweee

Thanks!! Worked for me.

@Fang-Haoshu I believe I managed to find the issue and got the setup running. I believe the way the c++ code was checking if it is a cuda tensor is no longer compatible with new versions of pytorch.

What I did to correct the issue is find occurrences of AT_CHECK in the c++ code and changed it to TORCH_CHECK. I had to change the following files: nms_cuda.cpp, roi_align_cuda.cpp, deform_cov_cuda.cpp, and deform_pool_cuda.cpp.

for example in the nms_cuda.cpp file the only change was

#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") to #define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")

After making that change the setup ran correctly. Best of luck.

mgholamikn avatar Feb 11 '21 02:02 mgholamikn

@Fang-Haoshu I believe I managed to find the issue and got the setup running. I believe the way the c++ code was checking if it is a cuda tensor is no longer compatible with new versions of pytorch.

What I did to correct the issue is find occurrences of AT_CHECK in the c++ code and changed it to TORCH_CHECK. I had to change the following files: nms_cuda.cpp, roi_align_cuda.cpp, deform_cov_cuda.cpp, and deform_pool_cuda.cpp.

for example in the nms_cuda.cpp file the only change was

#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") to #define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")

After making that change the setup ran correctly. Best of luck.

Thanks @angmc, I verified this fix to work for me as well.
For other people facing similar problems, the 4 files for changing AT_CHECK to TORCH_CHECK are in the following paths inside the AlphaPose directory:

alphapose/utils/roi_align/src/roi_align_cuda.cpp
alphapose/models/layers/dcn/src/deform_conv_cuda.cpp
alphapose/models/layers/dcn/src/deform_pool_cuda.cpp
detector/nms/src/nms_cuda.cpp

mimocha avatar Mar 15 '21 05:03 mimocha

Thanks, this PR has been merged to branch "pytorch<1.11"

Fang-Haoshu avatar Jun 22 '22 04:06 Fang-Haoshu

Thanks, this PR has been merged to branch "pytorch<1.11" Is it possible then to close this PR?

RichardKlem avatar Oct 31 '23 20:10 RichardKlem