I try to complete the official examples:

  
      
      GitHub
  
  
    

pytorch/extension-script 1

Example repository for custom C++/CUDA operators for TorchScript - pytorch/extension-script


  
  
    
    
  
  


After compiling, I encountered the following problems when calling the. So file:
OSError: /home/huang/vsopencv/extension-script/example_app/build/warp_perspective/libwarp_perspective.so: undefined symbol: _ZN3c1017RegisterOperators25checkSchemaAndRegisterOp_ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEONS0_7OptionsE
compiling：
(pytorch) huang@huang-ubuntu:/vsopencv/extension-script/example_app/warp_perspective/build$ cmake -DCMAKE_PREFIX_PATH=/home/huang/libtorch1.2.0/libtorch …
– The C compiler identification is GNU 7.4.0
– The CXX compiler identification is GNU 7.4.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Looking for pthread.h
– Looking for pthread.h - found
– Performing Test CMAKE_HAVE_LIBC_PTHREAD
– Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
– Looking for pthread_create in pthreads
– Looking for pthread_create in pthreads - not found
– Looking for pthread_create in pthread
– Looking for pthread_create in pthread - found
– Found Threads: TRUE
– Found CUDA: /usr/local/cuda-10.0 (found version “10.0”)
– Caffe2: CUDA detected: 10.0
– Caffe2: CUDA nvcc is: /usr/local/cuda-10.0/bin/nvcc
– Caffe2: CUDA toolkit directory: /usr/local/cuda-10.0
– Caffe2: Header version is: 10.0
– Found CUDNN: /usr/local/cuda-10.0/include
– Found cuDNN: v7.6.4 (include: /usr/local/cuda-10.0/include, library: /usr/local/cuda-10.0/lib64/libcudnn.so)
– Autodetected CUDA architecture(s): 7.5
– Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75
– Found torch: /home/huang/libtorch1.2.0/libtorch/lib/libtorch.so
– Pytorch status:
– libraries: torch;torch_library;/home/huang/libtorch1.2.0/libtorch/lib/libc10.so;/usr/lib/x86_64-linux-gnu/libcuda.so;/usr/local/cuda-10.0/lib64/libnvrtc.so;/usr/local/cuda-10.0/lib64/libnvToolsExt.so;/usr/local/cuda-10.0/lib64/libcudart.so;/home/huang/libtorch1.2.0/libtorch/lib/libc10_cuda.so
– Configuring done
– Generating done
– Build files have been written to: /home/huang/vsopencv/extension-script/example_app/warp_perspective/build
(pytorch) huang@huang-ubuntu:/vsopencv/extension-script/example_app/warp_perspective/build$ make
Scanning dependencies of target warp_perspective
[ 50%] Building CXX object CMakeFiles/warp_perspective.dir/op.cpp.o
/home/huang/vsopencv/extension-script/example_app/warp_perspective/op.cpp:11:78: warning: ‘torch::jit::RegisterOperators::RegisterOperators(const string&, Implementation&&) [with Implementation = at::Tensor (*)(at::Tensor, at::Tensor); std::__cxx11::string = std::__cxx11::basic_string]’ is deprecated [-Wdeprecated-declarations]
torch::jit::RegisterOperators(“my_ops::warp_perspective”, &warp_perspective);
^
In file included from /home/huang/libtorch1.2.0/libtorch/include/torch/script.h:5:0,
from /home/huang/vsopencv/extension-script/example_app/warp_perspective/op.cpp:1:
/home/huang/libtorch1.2.0/libtorch/include/torch/csrc/jit/custom_operator.h:28:3: note: declared here
RegisterOperators(const std::string& name, Implementation&& implementation) {
^~~~~~~~~~~~~~~~~
[100%] Linking CXX shared library libwarp_perspective.so
[100%] Built target warp_perspective
(pytorch) huang@huang-ubuntu:~/vsopencv/extension-script/example_app/warp_perspective/build$ cmake -DCMAKE_PREFIX_PATH=/home/huang/libtorch1.2.0/libtorch …