Vision: CMake build failed with error: 'class c10::OperatorHandle' has no member named 'typed'

Created on 13 Nov 2020  路  10Comments  路  Source: pytorch/vision

馃悰 Bug

To Reproduce

Steps to reproduce the behavior:

  1. Install PyTorch that was built myself, with build information:
#python3
Python 3.6.8 (default, Apr 20 2020, 14:49:33)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__config__.show())
PyTorch built with:
  - GCC 6.3
  - C++ Version: 201402
  - Intel(R) MKL-DNN v1.2.0 (Git Hash 70f8b879ea7a0c38caedb3320b7c85e8497ff50d)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 10.0
  - NVCC architecture flags: -gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75
  - CuDNN 7.6.3
  - Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DNDEBUG -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_INTERNAL_THREADPOOL_IMPL -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EIGEN_FOR_BLAS=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=OFF, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=0, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF,
  1. Resolve similar problem with the solution: https://github.com/pytorch/vision/issues/2001#issuecomment-611923412

@bmanga tow-names works.
just add these lines to the end of the CMakeLists.txt

set_property(TARGET torch_cuda PROPERTY INTERFACE_COMPILE_OPTIONS "")  
set_property(TARGET torch_cpu PROPERTY INTERFACE_COMPILE_OPTIONS "")
  1. Build vision with following commands:
source /opt/rh/devtoolset-6/enable
TORCH_DIR=/usr/local/lib64/python3.6/site-packages/torch
export CUDA_HOME=/usr/local/cuda
export CUDA_NVCC_EXECUTABLE=${CUDA_HOME}/bin/nvcc
export PATH=${CUDA_HOME}/bin/:$PATH
export TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5"

mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=${TORCH_DIR} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
make -j

Expected behavior

[ 88%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/cpu/nms_cpu.cpp.o
[ 94%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o
In file included from /home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/vision.cpp:14:0:
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/ROIAlign.h: In function 'at::Tensor roi_align(const at::Tensor&, const at::Tensor&, double, int64_t, int64_t, int64_t, bool)':
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/ROIAlign.h:29:25: error: 'class c10::OperatorHandle' has no member named 'typed'
                        .typed<decltype(roi_align)>();
                         ^~~~~
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/ROIAlign.h:29:31: error: expected primary-expression before 'decltype'
                        .typed<decltype(roi_align)>();
                               ^~~~~~~~
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/ROIAlign.h: In function 'at::Tensor _roi_align_backward(const at::Tensor&, const at::Tensor&, double, int64_t, int64_t, int64_t, int64_t, int6
4_t, int64_t, int64_t, bool)':
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/ROIAlign.h:77:12: error: 'class c10::OperatorHandle' has no member named 'typed'
           .typed<decltype(_roi_align_backward)>();
            ^~~~~
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/ROIAlign.h:77:18: error: expected primary-expression before 'decltype'
           .typed<decltype(_roi_align_backward)>();
                  ^~~~~~~~
In file included from /home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/vision.cpp:17:0:
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/nms.h: In function 'at::Tensor nms(const at::Tensor&, const at::Tensor&, double)':
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/nms.h:19:25: error: 'class c10::OperatorHandle' has no member named 'typed'
                        .typed<decltype(nms)>();
                         ^~~~~
/home/tianyou.gty/builds/blade2.0/vision_cpp/torchvision/csrc/nms.h:19:31: error: expected primary-expression before 'decltype'
                        .typed<decltype(nms)>();
                               ^~~~~~~~
make[2]: *** [CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/torchvision.dir/all] Error 2
make: *** [all] Error 2

Environment

PyTorch version: 1.6.0a0+9bfb91b
Is debug build: False
CUDA used to build PyTorch: 10.0
ROCM used to build PyTorch: N/A

OS: Linux 2.1903 LTS (Hunting Beagle) (x86_64)
GCC version: (GCC) 6.5.1 20191219
Clang version: Could not collect
CMake version: Could not collect

Python version: 3.6 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: 10.0.130
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: /usr/local/cuda-10.0/targets/x86_64-linux/lib/libcudnn.so.7.6.3
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.18.5
[pip3] torch==1.6.0a0+9bfb91b
[pip3] torchvision==0.7.0a0+11a39aa
[conda] Could not collect

Additional context

question build

Most helpful comment

@fortianyou Whops, didn't notice you already posted that, sorry.
That commit hash predates the 1.6 release and doesn't contain the required changes to successfully build torchvision.
Given your use case, I suggest you upgrade your torch version to the latest release and use torchvision master, as it has changes to make your use case work (eg. you can #include<torchvision/vision.h> in your project and that automatically registers all the operators).

@bmanga Great, that works for me after I changed to 1.6 release. Thanks a lot.

All 10 comments

hi @fortianyou,

We are currently discussing supporting CMake to build the library but this is still in progress (see #2349). For now we recommend using python setup.py install to install from source or python setup.py build develop if you plan to do development and modify the python files in-place. You can read more information on installing TorchVision from source here.

I'll close the ticket but if you face more issues, feel free to reopen it.

@datumbox The library should build fine with cmake already.

@fortianyou Which version of torchvision are you trying to build? With pytorch 1.6 you should be using 0.7.0.

@datumbox The library should build fine with cmake already.

@fortianyou Which version of torchvision are you trying to build? With pytorch 1.6 you should be using 0.7.0.

@bmanga I built with vision git commit 78ed10c that tagged v0.7.0

hi @fortianyou,

We are currently discussing supporting CMake to build the library but this is still in progress (see #2349). For now we recommend using python setup.py install to install from source or python setup.py build develop if you plan to do development and modify the python files in-place. You can read more information on installing TorchVision from source here.

I'll close the ticket but if you face more issues, feel free to reopen it.

Actually, I want to built something like libvision.so, that could be linked to libtorch. So that I could deploy a TorchScript Module with torchvision ops in C++.

And I have built with python setup.py install successfully. But it would produce python module _C.so, that is not expected.

@datumbox Could you please fix this bug first or propose some solution for this error? Do you have the clear timeline when to release the support of CMake ( #2349)?

@fortianyou It would be useful if you could add details of your use-case and explain what it will allow you to achieve on the linked RFC. We are always on the look out for adding features that add value to the community. At the moment there is no clear timeline for this feature but following the discussion on the RFC will keep you up-to-date on the progress.

@fortianyou what is the commit hash of the pytorch version that you built? It seems that it predates the addition of typed<> to the Dispatcher.

@fortianyou what is the commit hash of the pytorch version that you built? It seems that it predates the addition of typed<> to the Dispatcher.

@bmanga, Its commit hash is 9bfb91b. More compilation informations:

PyTorch built with:
  - GCC 6.3
  - C++ Version: 201402
  - Intel(R) MKL-DNN v1.2.0 (Git Hash 70f8b879ea7a0c38caedb3320b7c85e8497ff50d)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 10.0
  - NVCC architecture flags: -gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75
  - CuDNN 7.6.3
  - Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DNDEBUG -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_INTERNAL_THREADPOOL_IMPL -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EIGEN_FOR_BLAS=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=OFF, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=0, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF,

@fortianyou Whops, didn't notice you already posted that, sorry.
That commit hash predates the 1.6 release and doesn't contain the required changes to successfully build torchvision.
Given your use case, I suggest you upgrade your torch version to the latest release and use torchvision master, as it has changes to make your use case work (eg. you can #include<torchvision/vision.h> in your project and that automatically registers all the operators).

@fortianyou Whops, didn't notice you already posted that, sorry.
That commit hash predates the 1.6 release and doesn't contain the required changes to successfully build torchvision.
Given your use case, I suggest you upgrade your torch version to the latest release and use torchvision master, as it has changes to make your use case work (eg. you can #include<torchvision/vision.h> in your project and that automatically registers all the operators).

@bmanga Great, that works for me after I changed to 1.6 release. Thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Abolfazl-Mehranian picture Abolfazl-Mehranian  路  3Comments

ArashJavan picture ArashJavan  路  3Comments

ibtingzon picture ibtingzon  路  3Comments

feiyangsuo picture feiyangsuo  路  3Comments

300LiterPropofol picture 300LiterPropofol  路  3Comments