Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake error #1

Closed
Y-pandaman opened this issue Dec 8, 2020 · 12 comments
Closed

cmake error #1

Y-pandaman opened this issue Dec 8, 2020 · 12 comments

Comments

@Y-pandaman
Copy link

hello, thank you for your work, when I compile the program,It shown this error :
`SPDetector.hpp:51:10: error: ‘TensorOptions’ in namespace ‘c10’ does not name a type c10::TensorOptions tensor_opts;

error: ‘tensor_opts’ was not declared in this scope tensor_opts = c10::TensorOptions()

error: ‘TensorOptions’ is not a member of ‘c10’ tensor_opts = c10::TensorOptions()`
I do not know if you have this probelm, I am looking forward your reply.

@liubamboo
Copy link

maybe you can try to use c++-14 in CMakeLists.txt

@Y-pandaman
Copy link
Author

maybe you can try to use c++-14 in CMakeLists.txt

thank your reply, I try it, but it did not work. can you give me the latest cmakelists.txt file?

@liubamboo
Copy link

liubamboo commented Dec 12, 2020

@Y-pandaman I can make the project. The CMakeLists.txt is like:
cmake_minimum_required(VERSION 3.2)

project(
SuperPointCpp
VERSION 20.08
LANGUAGES CXX
DESCRIPTION "C++ Implementation of Superpoint."
)

set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)

LIBTORCH

#set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/libtorch")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/home/n609/install/libtorch-cxx11-abi-shared-with-deps-1.6.0/libtorch")
find_package(Torch REQUIRED QUIET)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
include_directories(${TORCH_INCLUDE_DIRS})

use libtorch 1.6.0

#set(Torch_DIR "/home/n609/install/pytorch1-6/pytorch/torch/share/cmake/Torch") # libtorch
#set(Caffe2_DIR "/home/n609/install/pytorch1-6/pytorch/torch/share/cmake/Caffe2")
#include_directories("/home/n609/install/pytorch1-6/pytorch/torch/include")

#find_package(Torch REQUIRED)

OPENCV

opencv dir is changed

set(OpenCV_DIR "/home/n609/install/opencv-3.2.0/build")
#find_package(OpenCV 3.4.11 QUIET)
find_package(OpenCV 3.2 QUIET)
message(STATUS "Found OpenCV version is ${OpenCV_VERSION}")
message(STATUS "Found OpenCV include is ${OpenCV_INCLUDE_DIRS}")
message(STATUS "Found OpenCV libraries is ${OpenCV_LIBS}")
include_directories(${OpenCV_INCLUDE_DIRS})

### ZED & CUDA

set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/zed")

find_package(ZED 3 REQUIRED)

find_package(CUDA ${ZED_CUDA_VERSION} EXACT REQUIRED)

include_directories(${ZED_INCLUDE_DIRS})

SUB_DIRECTORIES

add_subdirectory(src)
add_subdirectory(CreateVoca)

add_subdirectory(zed)

### Deprecated

add_executable(main main_SuperPoint.cpp)

target_compile_features(main PUBLIC cxx_std_14)

target_link_libraries(main PUBLIC

superpoint

#libzed

${TORCH_LIBRARIES}

${OpenCV_LIBS}

)

set_target_properties(main PROPERTIES

RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin"

)

Runfile to test new Framework.

add_executable(Test main.cpp)
target_compile_features(Test PUBLIC cxx_std_14)
target_link_libraries(Test PUBLIC
Super
${TORCH_LIBRARIES}

${OpenCV_LIBS}

)
set_target_properties(Test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin"
)

Runfile to create Vocabulary

add_executable(CreateVoca main_CreateVoca.cpp)
target_link_libraries(CreateVoca PUBLIC
Super
DBoW2
${TORCH_LIBRARIES}

${OpenCV_LIBS}

)
set_target_properties(CreateVoca PROPERTIES
CXX_STANDARD 11
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin"
)

But when I run the code, a bug appears:
Frame rate is 100ms.
terminate called after throwing an instance of 'c10::Error'
what(): open file failed, file path: ./Weights/superpoint.pt
Exception raised from FileAdapter at ../caffe2/serialize/file_adapter.cc:11 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x69 (0x7f961a0f9eb9 in /home/n609/install/libtorch-cxx11-abi-shared-with-deps-1.6.0/libtorch/lib/libc10.so)
frame #1: caffe2::serialize::FileAdapter::FileAdapter(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0x2f5 (0x7f960be514a5 in /home/n609/install/libtorch-cxx11-abi-shared-with-deps-1.6.0/libtorch/lib/libtorch_cpu.so)
frame #2: torch::jit::load(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, c10::optionalc10::Device, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::hash<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > >&) + 0x40 (0x7f960d254020 in /home/n609/install/libtorch-cxx11-abi-shared-with-deps-1.6.0/libtorch/lib/libtorch_cpu.so)
frame #3: torch::serialize::InputArchive::load_from(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, c10::optionalc10::Device) + 0x4a (0x7f960d5d854a in /home/n609/install/libtorch-cxx11-abi-shared-with-deps-1.6.0/libtorch/lib/libtorch_cpu.so)
frame #4: void torch::load<std::shared_ptrSuperPointSLAM::SuperPoint, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&>(std::shared_ptrSuperPointSLAM::SuperPoint&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&) + 0x49 (0x7f961a34bf99 in /home/n609/project/SuperPoint2CPP/lib/libSuper.so)
frame #5: SuperPointSLAM::SPDetector::SPDetector(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) + 0x15b (0x7f961a34848b in /home/n609/project/SuperPoint2CPP/lib/libSuper.so)
frame #6: main + 0x249 (0x561dfd50f7f9 in ./Test)
frame #7: __libc_start_main + 0xe7 (0x7f95c7680bf7 in /lib/x86_64-linux-gnu/libc.so.6)
frame #8: _start + 0x2a (0x561dfd50fe7a in ./Test)

maybe it can help you. And do you know how to solve this bug?

@liubamboo
Copy link

ok, I solve this bug. change the superpoint.pt relative dir to abosute dir.

@Y-pandaman
Copy link
Author

thanks for your reply, but I did not successed, I want to know if your libtorch file is unzipped and compiled? I did not compiled it, and use it directly. I have taken out all the comments of CMakeLists, it is like:

cmake_minimum_required(VERSION 3.2)

project(
SuperPointCpp
VERSION 20.08
LANGUAGES CXX
DESCRIPTION "C++ Implementation of Superpoint."
)

set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)

set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/home/user/thirdparty/libtorch1.6.0")
find_package(Torch REQUIRED QUIET)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
include_directories(${TORCH_INCLUDE_DIRS})

set(OpenCV_DIR "/home/user/thirdparty/opencv-3.4.11/build")
find_package(OpenCV 3.4.11 QUIET)
message(STATUS "Found OpenCV version is ${OpenCV_VERSION}")
message(STATUS "Found OpenCV include is ${OpenCV_INCLUDE_DIRS}")
message(STATUS "Found OpenCV libraries is ${OpenCV_LIBS}")
include_directories(${OpenCV_INCLUDE_DIRS})

add_subdirectory(src)
add_subdirectory(CreateVoca)

add_executable(Test main.cpp)
target_compile_features(Test PUBLIC cxx_std_14)
target_link_libraries(Test PUBLIC
Super
${TORCH_LIBRARIES}
)
set_target_properties(Test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin"
)

add_executable(CreateVoca main_CreateVoca.cpp)
target_link_libraries(CreateVoca PUBLIC
Super
DBoW2
${TORCH_LIBRARIES}
)
set_target_properties(CreateVoca PROPERTIES
CXX_STANDARD 11
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin"
)

@ChanWoo25
Copy link
Owner

ChanWoo25 commented Dec 14, 2020

Sorry for late answer.

At first, "TensorOptions" was also tricky when first implemented.
But now, my computer doesn't make any problem about it.

I think you can check whether cudatoolkit(10.2 ver) and cudnn are installed properly,
And try Re-install Libtorch using my INSTALL_Libtorch.sh.
I use LibTorch 1.6.0 version on Ubuntu 16.04 with GeForce RTX 2070 SUPER.

If you do things right, SuperPoint2CPP's root folder's CMakeLists.txt works perfect. And Please let me know if you find any problems I missed!

@Y-pandaman
Copy link
Author

thanks for your reply, I can use libtorch1.3.0 in other program, but I have compiled it. I download libtorch1.6 using INSTALL_LIBTORCH.sh and unzip it, but I did not compiled it ,I do not know if that is the reason.

@ChanWoo25
Copy link
Owner

ChanWoo25 commented Dec 14, 2020 via email

@Y-pandaman
Copy link
Author

Do you compile it with commands:

mkdir build
cd build
cmake ..
make

@ChanWoo25
Copy link
Owner

Umm... No.
The code you wrote is also a way to compile it.
I make runSuperPoint.sh for you. Check that shell file and test it.

@Y-pandaman
Copy link
Author

thanks for your reply, I try it, but it did not work.

user@robot:~/catkin_ws/src/sp/SuperPoint2CPP$ ./runSuperPoint.sh
-- Caffe2: CUDA detected: 10.0
-- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda
-- Caffe2: Header version is: 10.0
-- Found cuDNN: v7.5.1 (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so)
-- Autodetected CUDA architecture(s): 7.5 7.5
-- Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75
-- Found OpenCV version is 3.4.11
-- Found OpenCV include is /usr/local/include;/usr/local/include/opencv
-- Found OpenCV libraries is opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_viz;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_datasets;opencv_dnn_objdetect;opencv_dpm;opencv_face;opencv_freetype;opencv_fuzzy;opencv_hdf;opencv_hfs;opencv_img_hash;opencv_line_descriptor;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_reg;opencv_rgbd;opencv_saliency;opencv_sfm;opencv_stereo;opencv_structured_light;opencv_surface_matching;opencv_text;opencv_tracking;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
CreateVoca's home directory is /home/user/catkin_ws/src/sp/SuperPoint2CPP
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/catkin_ws/src/sp/SuperPoint2CPP
Unknown argument -t
Unknown argument SuperPoint
Usage: cmake --build

[options] [-- [native-options]]
Options:

= Project binary directory to be built. --target = Build instead of default targets. May only be specified once. --config = For multi-configuration tools, choose . --clean-first = Build target 'clean' first, then build. (To clean only, use --target 'clean'.) --use-stderr = Ignored. Behavior is default in CMake >= 3.0. -- = Pass remaining options to the native tool. ./runSuperPoint.sh: 行 4: ./bin/SuperPoint: 没有那个文件或目录

@ChanWoo25
Copy link
Owner

Error messages say that you build files are messed up.
Have you ever tried to remove build/ and CMake Re-configuration?

And I preferred to git clone my repository newly and build again. Also, you should know that "error: ‘tensor_opts’ was not declared in this scope tensor_opts = c10::TensorOptions()" may be caused by cuda-toolkit version. But you can fix it with small coding! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants