MVIG-SJTU / AlphaPose

Real-Time and Accurate Full-Body Multi-Person Pose Estimation&Tracking System
http://mvig.org/research/alphapose.html
Other
8.05k stars 1.98k forks source link

Error Building AlphaPose in Linux #1188

Open JamesMcCullochDickens opened 11 months ago

JamesMcCullochDickens commented 11 months ago

I am following the install.md docs and getting the following error during my build:

My OS is Ubuntu 22.04.

Error compiling Cython file:

...

distutils: language = c

^

halpecocotools/_mask.pyx:1:0: Compiler crash in RemoveUnreachableCode

ModuleNode.body = StatListNode(_mask.pyx:1:0)

Compiler crash traceback from this point on: File "Cython/Compiler/Visitor.py", line 182, in Cython.Compiler.Visitor.TreeVisitor._visit File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 3112, in visit_StatListNode if not self.current_directives['remove_unreachable']: TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "setup.py", line 214, in zip_safe=False) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/init.py", line 107, in setup return distutils.core.setup(attrs) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/develop.py", line 34, in run self.install_for_development() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/develop.py", line 126, in install_for_development self.process_distribution(None, self.dist, not self.no_deps) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 751, in process_distribution [requirement], self.local_index, self.easy_install File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/pkg_resources/init.py", line 830, in resolve req, best, replace_conflicting, env, installer, required_by, to_activate File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/pkg_resources/init.py", line 866, in _resolve_dist req, ws, installer, replace_conflicting=replace_conflicting File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/pkg_resources/init.py", line 1135, in best_match return self.obtain(req, installer) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/pkg_resources/init.py", line 1147, in obtain return installer(requirement) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 677, in easy_install return self.install_item(spec, dist.location, tmpdir, deps) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 703, in install_item dists = self.install_eggs(spec, download, tmpdir) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 896, in install_eggs return self.build_and_install(setup_script, setup_base) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 1170, in build_and_install self.run_setup(setup_script, setup_base, args) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 1154, in run_setup run_setup(setup_script, args) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/sandbox.py", line 262, in run_setup raise File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/contextlib.py", line 130, in exit self.gen.throw(type, value, traceback) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/sandbox.py", line 198, in setup_context yield File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/contextlib.py", line 130, in exit self.gen.throw(type, value, traceback) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/sandbox.py", line 169, in save_modules saved_exc.resume() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/sandbox.py", line 143, in resume raise exc.with_traceback(self._tb) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/sandbox.py", line 156, in save_modules yield saved File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/sandbox.py", line 198, in setup_context yield File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/sandbox.py", line 259, in run_setup _execfile(setup_script, ns) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/sandbox.py", line 46, in _execfile exec(code, globals, locals) File "/tmp/easy_install-9pxyloow/halpecocotools-0.0.0/setup.py", line 28, in def _minimal_ext_cmd(cmd): File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/init.py", line 107, in setup return distutils.core.setup(attrs) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 164, in run cmd = self.call_command('install_lib', warn_dir=0) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 150, in call_command self.run_command(cmdname) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/install_lib.py", line 11, in run self.build() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/command/install_lib.py", line 111, in build self.run_command('build_ext') File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 84, in run _build_ext.run(self) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run self.build_extensions() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions self._build_extensions_serial() File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial self.build_extension(ext) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 246, in build_extension _build_ext.build_extension(self, ext) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Distutils/build_ext.py", line 131, in build_extension ext,force=self.force, quiet=self.verbose == 0, *options File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize cythonize_one(args) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1300, in cythonize_one result = compile_single(pyx_file, options, full_module_name=full_module_name) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Compiler/Main.py", line 615, in compile_single return run_pipeline(source, options, full_module_name) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Compiler/Main.py", line 539, in run_pipeline err, enddata = Pipeline.run_pipeline(pipeline, source) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Compiler/Pipeline.py", line 398, in run_pipeline data = run(phase, data) File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Compiler/Pipeline.py", line 375, in run return phase(data) File "Cython/Compiler/Visitor.py", line 312, in Cython.Compiler.Visitor.CythonTransform.call File "Cython/Compiler/Visitor.py", line 294, in Cython.Compiler.Visitor.VisitorTransform.call File "Cython/Compiler/Visitor.py", line 184, in Cython.Compiler.Visitor.TreeVisitor._visit File "Cython/Compiler/Visitor.py", line 182, in Cython.Compiler.Visitor.TreeVisitor._visit File "Cython/Compiler/Visitor.py", line 322, in Cython.Compiler.Visitor.CythonTransform.visit_Node File "Cython/Compiler/Visitor.py", line 260, in Cython.Compiler.Visitor.VisitorTransform._process_children File "Cython/Compiler/Visitor.py", line 227, in Cython.Compiler.Visitor.TreeVisitor._visitchildren File "Cython/Compiler/Visitor.py", line 196, in Cython.Compiler.Visitor.TreeVisitor._visitchild File "Cython/Compiler/Visitor.py", line 190, in Cython.Compiler.Visitor.TreeVisitor._visit File "Cython/Compiler/Visitor.py", line 148, in Cython.Compiler.Visitor.TreeVisitor._raise_compiler_error setuptools.sandbox.UnpickleableException: CompilerCrash((<FileSourceDescriptor:/tmp/easy_install-9pxyloow/halpecocotools-0.0.0/halpecocotools/_mask.pyx>, 1, 0), 'RemoveUnreachableCode', 'Compiler crash in RemoveUnreachableCode\n\nModuleNode.body = StatListNode(_mask.pyx:1:0)\n\nCompiler crash traceback from this point on:\n File "Cython/Compiler/Visitor.py", line 182, in Cython.Compiler.Visitor.TreeVisitor._visit\n File "/home/james/anaconda3/envs/alphapose_r/lib/python3.7/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 3112, in visit_StatListNode\n if not self.current_directives[\'remove_unreachable\']:\nTypeError: \'NoneType\' object is not subscriptable', TypeError("'NoneType' object is not subscriptable"), <traceback object at 0x7efb9e25e370>

The exact instructions I followed were as follows:

Get CUDA

sudo apt update sudo apt install nvidia-cuda-toolkit

1. Create a conda virtual environment.

conda create -n alphapose python=3.7 -y conda activate alphapose

2. Install PyTorch

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch

3. Get AlphaPose

git clone https://github.com/MVIG-SJTU/AlphaPose.git cd AlphaPose

4. install

export PATH=/usr/local/cuda/bin/:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH pip install -U pip setuptools python -m pip install cython sudo apt-get install libyaml-dev python setup.py build develop

JamesL404 commented 11 months ago

I have the same issue, did you fix it?

JamesMcCullochDickens commented 11 months ago

@JamesL404 This for me is working so far: // Create a conda virtual environment. conda create -n alphapose python=3.7 -y conda activate alphapose conda install -c "nvidia/label/cuda-11.3.1" cuda-toolkit -y

// 2. Install PyTorch conda install pytorch torchvision torchaudio pytorch-cuda=11.3 -c pytorch -c nvidia

// Get AlphaPose git clone https://github.com/MVIG-SJTU/AlphaPose.git cd AlphaPose

// install export PATH=/usr/local/cuda/bin/:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH pip install -U pip setuptools pip install cython==0.27.3 sudo apt-get install libyaml-dev pip install easydict halpecocotools munkres natsort opencv-python pyyaml scipy tensorboardx terminaltables timm==0.1.20 tqdm visdom jinja2 typeguard python setup.py build develop

// Install PyTorch3D (Optional, only for visualization) conda install -c fvcore -c iopath -c conda-forge fvcore iopath -y conda install -c bottler nvidiacub -y pip install pytorch3d

A couple of additional thoughts. I am using gcc 9.5, and Ubuntu 22.04. The two most important fixes in this different set of installation instructions was the cython version as well as the cuda toolkit version used (not part of PyTorch, but a separate install).

If you have gcc issues, checkout: https://github.com/MVIG-SJTU/AlphaPose/issues/1157#issuecomment-1734703528

JamesL404 commented 11 months ago

it works, I think Cython version is the main issue, thanks!

avegetablechicken commented 11 months ago

@JamesL404 This for me is working so far: // Create a conda virtual environment. conda create -n alphapose python=3.7 -y conda activate alphapose conda install -c "nvidia/label/cuda-11.3.1" cuda-toolkit -y

// 2. Install PyTorch conda install pytorch torchvision torchaudio pytorch-cuda=11.3 -c pytorch -c nvidia

// Get AlphaPose git clone https://github.com/MVIG-SJTU/AlphaPose.git cd AlphaPose

// install export PATH=/usr/local/cuda/bin/:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH pip install -U pip setuptools pip install cython==0.27.3 sudo apt-get install libyaml-dev pip install easydict halpecocotools munkres natsort opencv-python pyyaml scipy tensorboardx terminaltables timm==0.1.20 tqdm visdom jinja2 typeguard python setup.py build develop

// Install PyTorch3D (Optional, only for visualization) conda install -c fvcore -c iopath -c conda-forge fvcore iopath -y conda install -c bottler nvidiacub -y pip install pytorch3d

A couple of additional thoughts. I am using gcc 9.5, and Ubuntu 22.04. The two most important fixes in this different set of installation instructions was the cython version as well as the cuda toolkit version used (not part of PyTorch, but a separate install).

If you have gcc issues, checkout: #1157 (comment)

Exactly followed your commands and it worked for Ubuntu18.04. Thanks!

benrubin commented 11 months ago

Hi @JamesMcCullochDickens and @JamesL404 -- I'm having all kinds of similar installation problems (Ubuntu 20.04). I'm happy to see that you are both getting this to work! I'm now stepping through the instructions above, but I'm stuck on step 2. I'm hoping you can help!

When I run $ conda install pytorch torchvision torchaudio pytorch-cuda=11.3 -c pytorch -c nvidia

I get this:

PackagesNotFoundError: The following packages are not available from current channels:
  - pytorch-cuda=11.3

Current channels:

  - https://conda.anaconda.org/pytorch/linux-64
  - https://conda.anaconda.org/pytorch/noarch
  - https://conda.anaconda.org/nvidia/linux-64
  - https://conda.anaconda.org/nvidia/noarch
  - https://aws-ml-conda-ec2.s3.us-west-2.amazonaws.com/linux-64
  - https://aws-ml-conda-ec2.s3.us-west-2.amazonaws.com/noarch
  - https://conda.anaconda.org/conda-forge/linux-64
  - https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

I've searched for pytorch-cuda=11.3 on https://anaconda.org, but no luck.

Any advice?

JamesMcCullochDickens commented 11 months ago

@benrubin try: conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch

You can see conda commands to install previous versions here, you just need to make sure you use cudatoolkit 11.3. https://pytorch.org/get-started/previous-versions/

benrubin commented 11 months ago

Wow -- installed without errors at last! Thank you so much. Now comes the real work.

anas-zafar commented 10 months ago

@JamesL404 I followed your instructions, I am facing this issue when I run the train command

from . import nms_cpu, nms_cuda
ImportError: /home/train/Desktop/AlphaPose/detector/nms/nms_cpu.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe28TypeMeta21_typeMetaDataInstanceIdEEPKNS_6detail12TypeMetaDataEv

Can you please guide me what am I doing wrong? Thanks

zdl12345678 commented 5 months ago

@anas-zafar I encountered the same problem while inference, have you solved it?

Wang-Wenqing commented 3 months ago

@JamesL404 This for me is working so far: // Create a conda virtual environment. conda create -n alphapose python=3.7 -y conda activate alphapose conda install -c "nvidia/label/cuda-11.3.1" cuda-toolkit -y

// 2. Install PyTorch conda install pytorch torchvision torchaudio pytorch-cuda=11.3 -c pytorch -c nvidia

// Get AlphaPose git clone https://github.com/MVIG-SJTU/AlphaPose.git cd AlphaPose

// install export PATH=/usr/local/cuda/bin/:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH pip install -U pip setuptools pip install cython==0.27.3 sudo apt-get install libyaml-dev pip install easydict halpecocotools munkres natsort opencv-python pyyaml scipy tensorboardx terminaltables timm==0.1.20 tqdm visdom jinja2 typeguard python setup.py build develop

// Install PyTorch3D (Optional, only for visualization) conda install -c fvcore -c iopath -c conda-forge fvcore iopath -y conda install -c bottler nvidiacub -y pip install pytorch3d

A couple of additional thoughts. I am using gcc 9.5, and Ubuntu 22.04. The two most important fixes in this different set of installation instructions was the cython version as well as the cuda toolkit version used (not part of PyTorch, but a separate install).

If you have gcc issues, checkout: #1157 (comment)

I cannot install cython==0.27.3, but cython==0.29.20 work for me

RaphaelLorenzo commented 1 month ago

@JamesL404 This for me is working so far: // Create a conda virtual environment. conda create -n alphapose python=3.7 -y conda activate alphapose conda install -c "nvidia/label/cuda-11.3.1" cuda-toolkit -y

// 2. Install PyTorch conda install pytorch torchvision torchaudio pytorch-cuda=11.3 -c pytorch -c nvidia

// Get AlphaPose git clone https://github.com/MVIG-SJTU/AlphaPose.git cd AlphaPose

// install export PATH=/usr/local/cuda/bin/:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH pip install -U pip setuptools pip install cython==0.27.3 sudo apt-get install libyaml-dev pip install easydict halpecocotools munkres natsort opencv-python pyyaml scipy tensorboardx terminaltables timm==0.1.20 tqdm visdom jinja2 typeguard python setup.py build develop

// Install PyTorch3D (Optional, only for visualization) conda install -c fvcore -c iopath -c conda-forge fvcore iopath -y conda install -c bottler nvidiacub -y pip install pytorch3d

A couple of additional thoughts. I am using gcc 9.5, and Ubuntu 22.04. The two most important fixes in this different set of installation instructions was the cython version as well as the cuda toolkit version used (not part of PyTorch, but a separate install).

If you have gcc issues, checkout: #1157 (comment)

Thanks for the solution, I followed your steps and fixed the GCC and CUDA path issues as mentioned and it worked but then I also had issues when setup.py tried installing pycocotools (SystemError: NULL result without error in PyObject_Call) so i just installed it with pip using the command here : https://github.com/MVIG-SJTU/AlphaPose/blob/c60106d19afb443e964df6f06ed1842962f5f1f7/setup.py#L218 (I'm using Ubuntu 22.04)

python -m pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

Then again : python setup.py build develop