ceccocats / tkDNN

Deep neural network library and toolkit to do high performace inference on NVIDIA jetson platforms
GNU General Public License v2.0
718 stars 209 forks source link

how can i use libtkDNN.so in a new project? please help #110

Closed jcyhcs closed 3 years ago

jcyhcs commented 4 years ago

ok, i use have a new c++11 project, use cmake as compile. i install tkDNN in /usr/local/lib, and tkDNN include as /usr/local/include/tkDNN, but when i compile i get error: undefined reference to symbol 'cudaGetErrorString@@libcudart.so.10.0'

how can i use libtkDNN.so into my project?? my cmakefile.txt like this: image

ceccocats commented 4 years ago

You need to link all the libraries The easyest way is to use find_package(tkDNN) It will load the config from: https://github.com/ceccocats/tkDNN/blob/master/cmake/tkDNNConfig.cmake

You will have the include dirs in tkDNN_INCLUDE_DIRS and the libraries to link in tkDNN_LIBRARIES

nightduck commented 3 years ago

Stumbled on this issue, figured out the specifics. For future googlers after me, you have to install this repo, by running sudo make install after building. Then link it by adding the relevant code below to your CMakeLists.txt file:

find_package(tkDNN REQUIRED)

include_directories(
    ${tkDNN_INCLUDE_DIRS}
    /usr/local/include/tkDNN
)

add_executable(program_name src/program_code.cpp)
target_link_libraries(program_name ${tkDNN_LIBRARIES})

Be sure the library is added to your LD_LIBRARY_PATH variable, otherwise your executable won't run.

echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib" >> ~/.bashrc

If @jcyhcs has fixed their problem, you can probably close this issue

mive93 commented 3 years ago

Yes, @nightduck that is correct. If you want another real example where I use it as submodule you can check this https://github.com/mive93/class-edge/blob/master/CMakeLists.txt

I will close the issue for now, feel free to reopen it.