How to succeed use LibTorch with OpenCV?

Cannoooooot build successfully!

  • 1st trial:
    using pip3.6 install to install pytorch1.0 and download libtorch zip file.
    cannot use it with opencv, throwing error of undefined error imread

  • 2nd trial
    build from source! Always report this:

Install the project... 
-- Install configuration: "Release" 

-- Set runtime path of "/data/lvjc/pytorch/torch/lib/tmp_install/lib/libmkldnn.so.0.17.0" to "$ORIGIN:/data/lvjc/envs/anaconda2/lib" 

-- Set runtime path of "/data/lvjc/pytorch/torch/lib/tmp_install/lib/libc10.so" to "$ORIGIN" 

-- Set runtime path of "/data/lvjc/pytorch/torch/lib/tmp_install/lib/libc10_cuda.so" to "$ORIGIN" 

-- Set runtime path of "/data/lvjc/pytorch/torch/lib/tmp_install/lib/libcaffe2.so" to "$ORIGIN:/data/lvjc/envs/anaconda2/lib:/usr/local/cuda/lib64" 

-- Set runtime path of "/data/lvjc/pytorch/torch/lib/tmp_install/lib/libcaffe2_gpu.so" to "$ORIGIN:/data/lvjc/envs/anaconda2/lib:/usr/local/cuda/lib64" 

-- Set runtime path of "/data/lvjc/pytorch/torch/lib/tmp_install/lib/libtorch.so.1" to "$ORIGIN:/usr/local/cuda/lib64:/data/lvjc/envs/anaconda2/lib" 

-- Set runtime path of "/data/lvjc/pytorch/torch/lib/tmp_install/lib/libcaffe2_module_test_dynamic.so" to "$ORIGIN:/data/lvjc/envs/anaconda2/lib" 

ls: cannot access 'build.ninja': No such file or directory

I can understand some frustration, but am not a big fan of offensive language.
I’ve edited the topic and your post.

Could you post your install steps and CMakeFiles.txt?
The current information is a bit sparse.

I have tried soooo hard to build again and again. I will show you.
Setups:

  • Docker version 18.06.1-ce, build e68fc7a
  • CUDA 9.0
  • Anaconda 3
  • CMAKE 3.11.1 (conda)
  • GCC G++ 5.4
  • Build PyTorch from source
  • Download LibTorch from official site(tried from source but receive error ls: cannot access 'build.ninja': No such file or directory)
  • OpenCV3.4.1 from conda install opencv (have tried build version 4.0.0 from source but received error target opencv_ts; Makefile:162: recipe for target 'all' failed; make: *** [all] Error 2)

Now I want to try run this demo using libtorch https://github.com/iamhankai/cpp-pytorch
But I am always RECEIVING ERROR!
This is CMakeLists.txt:

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(custom_ops)

find_package(Torch REQUIRED)

find_package( OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )

add_executable(example-app example-app.cpp)
target_link_libraries(example-app ${TORCH_LIBRARIES} ${OpenCV_LIBS})
set_property(TARGET example-app PROPERTY CXX_STANDARD 11)

Thanks for the info.
As far as I know you won’t be able to include OpenCV in your C++ application by using the conda version, but would need to build it.
It looks currently as if your issue is related to OpenCV.
To get a better error message, you might run the build with make VERBOSE=1.