I’m trying to compile my C++ code which depends on libtorch using CMake. Here is my CMakeList.txt:

cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
SET(PROJECT_NAME inference)
project(${PROJECT_NAME})
set(EXECUTABLE_OUTPUT_PATH ../bin)

SET(CMAKE_C_COMPILER g++)
if(CMAKE_COMPILER_IS_GNUCXX)
    add_compile_options(-std=c++11 -fno-stack-protector) # very important key in TK1,otherwise will raise an error call stack smashing detected
    message(STATUS "optional:-std=c++11")
endif(CMAKE_COMPILER_IS_GNUCXX)

set(opencv_dir ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/opencv_4.2.0)
file(GLOB OpenCV_LIBS ${opencv_dir}/lib/*.so)


set(Torch_DIR ../third_party/libtorch/share/cmake/Torch)
find_package(Torch REQUIRED)

set(third_party_includes ../third_party/opencv_4.2.0/include ../third_party/libtorch/include
                         ../third_party/libtorch/include/torch/csrc/api/include/)


add_executable(${PROJECT_NAME} ../src/test.cpp)
include_directories(${PROJECT_NAME}/include)
include_directories(${PROJECT_NAME}/include/clipper)
target_include_directories(${PROJECT_NAME} PUBLIC ${third_party_includes})
target_link_libraries(${PROJECT_NAME} ${TORCH_LIBRARIES} ${OpenCV_LIBS})

SET(CMAKE_BUILD_TYPE DEBUG)


after I executed cmake --build . , error occurred:
(base) work@49fa12a97d74w:/home/ton/inference/build$ cmake --build .
-- optional:-std=c++11
-- Caffe2: CUDA detected: 10.1
-- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda
-- Caffe2: Header version is: 10.1
-- Found cuDNN: v7.6.5  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libcudnn.so)
-- Automatic GPU detection failed. Building for common architectures.
-- Autodetected CUDA architecture(s): 3.5;5.0;5.2;6.0;6.1;7.0;7.0+PTX;7.5;7.5+PTX
-- Added CUDA NVCC flags for: -gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_70,code=compute_70;-gencode;arch=compute_75,code=compute_75
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ton/inference/build
[ 50%] Linking CXX executable /home/ton/inference/bin/inference
/usr/bin/ld: cannot find -lCUDA_cublas_LIBRARY-NOTFOUND
collect2: error: ld returned 1 exit status
CMakeFiles/inference.dir/build.make:123: recipe for target '/home/ton/inference/bin/inference' failed
make[2]: *** [/home/ton/inference/bin/inference] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/inference.dir/all' failed
make[1]: *** [CMakeFiles/inference.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

How to solve it ? Thanks in advance.