0

So I'm trying to use tensorflow lite c++ with OpenCL support on windows. So far these are the steps I've followed:

  • Clone tensorflow github repo to tensorflow_src and checout to r2.14
  • Create a folder called tflite-opencl next to the cloned repo
  • Go to tflite-opencl and run cmake C:/Users/Asus/Desktop/tensorflow_src/tensorflow/lite -DTFLITE_ENABLE_GPU=ON
  • Run cmake --build . -j

This gave me tensorflow-lite.lib under tflite-opencl/Debug but there are no .dll files. I've tried to use that lib file in my project with this cmake :

cmake_minimum_required(VERSION 3.16)
project(OpenCLTest C CXX)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third-party/include/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third-party/include/flatbuffers/include)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../third-party/include/opencl)

link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third-party/lib/)
# find_library(libflatbuffer flatbuffers  HINTS ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/include/lib)
# Add source to this project's executable.
add_executable (OpenCLTest "OpenCLTest.cpp" "OpenCLTest.h")

 target_link_libraries(OpenCLTest 
     PUBLIC 
     tensorflow-lite
     flatbuffers
     OpenCL
 )

But no matter how I try to configure my cmake, I always get an undefined symbol error on many functions, the error code is so long I can't paste it here, but it's generally undefined symbols. Here are some notable parts of the error code I thought I should share to give you an idea:

Error   LNK2038 mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in OpenCLTest.obj  
Error   LNK2038 mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in OpenCLTest.obj
Error   LNK2001 unresolved external symbol "class ruy::Ctx * __cdecl ruy::get_ctx(class ruy::Context *)" (?get_ctx@ruy@@YAPEAVCtx@1@PEAVContext@1@@Z)   
Severity    Code    Description Project File    Line    Suppression State
Error   LNK2001 unresolved external symbol "int __cdecl ruy::detail::MultiplyByQuantizedMultiplier(int,int,int)" (?MultiplyByQuantizedMultiplier@detail@ruy@@YAHHHH@Z)  
Error   LNK2001 unresolved external symbol "public: class ruy::Allocator * __cdecl ruy::Ctx::GetMainAllocator(void)" (?GetMainAllocator@Ctx@ruy@@QEAAPEAVAllocator@2@XZ)        1   

And the rest is similar unresolved external symbol errors. I'm using visual studio's cmake project type to build this, what am I doing wrong? Is my build faulty? Was I supposed to get a dll aswell?

Turgut
  • 711
  • 3
  • 25
  • The error "LNK2038 mismatch detected for" means that different part of your executable use different variants of CRT: https://stackoverflow.com/questions/14714877/mismatch-detected-for-runtimelibrary. You are better to fix that error before looking into other errors. – Tsyvarev Aug 29 '23 at 08:39
  • You must consistently have *either* Debug or Release build for all your components. Mixing just doesn't work. For example, `_ITERATOR_DEBUG_LEVEL` changes the layout of some standard library classes. – BoP Aug 29 '23 at 09:20
  • @BoP I'm not %100 sure but I think I have all of them on debug, I'll double check tho. – Turgut Aug 29 '23 at 09:41

0 Answers0