pose-ae-train 出错error: dereferencing pointer to incomplete type ‘THTensor {aka struct THTensor}’

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012435142/article/details/81747505

最近在学习人体姿态估计,配置pose-ae-train时出现错误,多次试验后将解决方法记录下来,希望能帮助到其他人。
pose-ae-train链接:https://github.com/umich-vl/pose-ae-train

extensions/AE/ 目录下python build.py install出错

(base) han@MS:/media/han/E/mWork/mCode/pose-ae-train/extensions/AE$ python build.py install
Including CUDA code.
generating /tmp/tmpo978nske/_my_lib.c
setting the current directory to '/tmp/tmpo978nske'
running build_ext
building '_my_lib' extension
creating media
creating media/han
creating media/han/E
creating media/han/E/mWork
creating media/han/E/mWork/mCode
creating media/han/E/mWork/mCode/pose-ae-train
creating media/han/E/mWork/mCode/pose-ae-train/extensions
creating media/han/E/mWork/mCode/pose-ae-train/extensions/AE
creating media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src
gcc -pthread -B /home/han/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/home/han/anaconda3/include/python3.6m -c _my_lib.c -o ./_my_lib.o -std=c99
gcc -pthread -B /home/han/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/home/han/anaconda3/include/python3.6m -c /media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src/my_lib.c -o ./media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src/my_lib.o -std=c99
/media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src/my_lib.c: In function ‘my_lib_loss_forward’:
/media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src/my_lib.c:14:30: error: dereferencing pointer to incomplete type ‘THTensor {aka struct THTensor}’
     const int batchsize = Tag->size[0];
                              ^
Traceback (most recent call last):
  File "/home/han/anaconda3/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/home/han/anaconda3/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/home/han/anaconda3/lib/python3.6/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/home/han/anaconda3/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/han/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 51, in _build
    dist.run_command('build_ext')
  File "/home/han/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/han/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/home/han/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()
  File "/home/han/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)
  File "/home/han/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/home/han/anaconda3/lib/python3.6/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/home/han/anaconda3/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "build.py", line 34, in <module>
    ffi.build()
  File "/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 189, in build
    _build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
  File "/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 111, in _build_extension
    outfile = ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
  File "/home/han/anaconda3/lib/python3.6/site-packages/cffi/api.py", line 697, in compile
    compiler_verbose=verbose, debug=debug, **kwds)
  File "/home/han/anaconda3/lib/python3.6/site-packages/cffi/recompiler.py", line 1520, in recompile
    compiler_verbose, debug)
  File "/home/han/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 22, in compile
    outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
  File "/home/han/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 58, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.error.VerificationError: CompileError: command 'gcc' failed with exit status 1

解决方法

参考issues:
https://github.com/pytorch/pytorch/issues/8483
根据网上的讨论,认为是pytorch版本兼容问题,将pytorch 0.4.1换成pytorch 0.4.0就可以了
安装pytorch 0.4.0版本参考: https://pytorch.org/previous-versions/
注意选择相应的CUDA版本和Python版本

pip install http://download.pytorch.org/whl/cu90/torch-0.4.0-cp36-cp36m-linux_x86_64.whl

重新安装pytorch 0.4.0版本后,执行结果为:

(base) han@MS:/media/han/E/mWork/mCode/pose-ae-train/extensions/AE$ python build.py install
Including CUDA code.
generating /tmp/tmpviozfstm/_my_lib.c
setting the current directory to '/tmp/tmpviozfstm'
running build_ext
building '_my_lib' extension
creating media
creating media/han
creating media/han/E
creating media/han/E/mWork
creating media/han/E/mWork/mCode
creating media/han/E/mWork/mCode/pose-ae-train
creating media/han/E/mWork/mCode/pose-ae-train/extensions
creating media/han/E/mWork/mCode/pose-ae-train/extensions/AE
creating media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src
gcc -pthread -B /home/han/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/home/han/anaconda3/include/python3.6m -c _my_lib.c -o ./_my_lib.o
gcc -pthread -B /home/han/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/han/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/home/han/anaconda3/include/python3.6m -c /media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src/my_lib.c -o ./media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src/my_lib.o
gcc -pthread -shared -B /home/han/anaconda3/compiler_compat -L/home/han/anaconda3/lib -Wl,-rpath=/home/han/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ ./_my_lib.o ./media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src/my_lib.o /media/han/E/mWork/mCode/pose-ae-train/extensions/AE/src/my_lib_kernel.o -o ./_my_lib.so

猜你喜欢

转载自blog.csdn.net/u012435142/article/details/81747505