LibTorch with CMake via Eclipse in Windows:Terminated exit value 390

江枫思渺然 提交于 2019-12-13 04:18:29

问题


I used cmake4eclipse to build torch C++ version 1.0 stable in Windows 10. Basically, I have the following CMakeLists.txt to build the mnist example:

cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(mnist)

set(CMAKE_PREFIX_PATH "C:/rl/libtorch/share/cmake/Torch")
set(Torch_DIR "C:/rl/libtorch")

find_package(Torch REQUIRED)

option(DOWNLOAD_MNIST "Download the MNIST dataset from the internet" ON)
if (DOWNLOAD_MNIST)
  message(STATUS "Downloading MNIST dataset")
  execute_process(
    COMMAND python ${CMAKE_CURRENT_LIST_DIR}/download_mnist.py
      -d ${CMAKE_BINARY_DIR}/data
    ERROR_VARIABLE DOWNLOAD_ERROR)
  if (DOWNLOAD_ERROR)
    message(FATAL_ERROR "Error downloading MNIST dataset: ${DOWNLOAD_ERROR}")
  endif()
endif()

set(CMAKE_BUILD_TYPE Debug) 
add_executable(mnist mnist.cpp)
target_compile_features(mnist PUBLIC cxx_range_for)
set_property(TARGET mnist PROPERTY CXX_STANDARD 14)
target_link_libraries(mnist ${TORCH_LIBRARIES})

Then, I load this along with the mnist.cpp and download_mnist.py files in a folder and start a project in eclipse IDE for C/C++, version 2018-09 (4.9.0). In project_properties->C/C++ Build->Tool Chain Editor, I set CMake Builder (GNU Make) and select MinGW GCC. Then, in project_properties->C/C++ General->Preprocessor Include Paths Macros etc.->Providers I select CMAKE_EXPORT_COMPILE_COMMANDS Parser [Shared] and move it up, as it is explained here.

Then, I can compile the mnist project without any error. But, when I run it get <terminated> (exit value 390) a.exe [some address]. I tried to debug this code to find out the problem, but I cannot see the debug screen, and instead I get:

Running the debug mode to the end results in a same error. I can run mnist.cpp in Linux without any problem, though I use cmake -G "Eclipse CDT4 - Unix Makefiles" ./ to create a eclipse project. I did not know how I can use cmake -G "Eclipse CDT4 - Unix Makefiles" ./ in Windows and I used cmake4eclipse and I believe I have missed a step in dealing with the CMakeLists.txt file in windows. I appreciate any help or comments.

Thanks, Afshin


回答1:


I asked same question in torch git, and today I got an answer for that. It seems that for now, we will not be able to run Libtorch through Eclipse with MinGw. Here is the answer that I got from torch git page:

"I don't think you could build that with MinGW because the code is written in c++ and MinGW is not abi-compatible with MSVC. So I think you may need to compile with MSVC. And also in MSVC, the configuration debug and release could not be mixed. So you will have to choose Release as we only provide library with the Release configuration."

See more details in: https://github.com/pytorch/pytorch/issues/15711



来源:https://stackoverflow.com/questions/53873603/libtorch-with-cmake-via-eclipse-in-windowsterminated-exit-value-390

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!