CUDA cannot found while building libtorch

Hi all
I have problem while building using libtorch.
I tried to solve this problem myself, But i couldn’t solve toe problem for a long time,
so i wrote a post to get hlep.

I using Linux(centos7) CUDA 10 version libtorch zip.
I tried to check whether the example code was executed by following the link above.

But, cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch .. command error occur.

Below is the error message.

-- Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (found version "10.2")
CMake Warning at /disk1/puzzlebook/libtorch/share/cmake/Caffe2/public/cuda.cmake:31 (message):
  Caffe2: CUDA cannot be found.  Depending on whether you are building Caffe2
  or a Caffe2 dependent library, the next warning / error will give you more
Call Stack (most recent call first):
  /disk1/puzzlebook/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:88 (include)
  /disk1/puzzlebook/libtorch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
  CMakeLists.txt:6 (find_package)

CMake Error at /disk1/puzzlebook/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:90 (message):
  Your installed Caffe2 version uses CUDA but I cannot find the CUDA
  libraries.  Please set the proper CUDA prefixes and / or install CUDA.
Call Stack (most recent call first):
  /disk1/puzzlebook/libtorch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
  CMakeLists.txt:6 (find_package)

-- Configuring incomplete, errors occurred!
See also "/disk1/puzzlebook/example-app/build/CMakeFiles/CMakeOutput.log".
See also "/disk1/puzzlebook/example-app/build/CMakeFiles/CMakeError.log".

nvcc -V result is

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89

and echo $CUDA_HOME result is

I made a lot of effort to solve the problem myself, but I couldn’t solve it, so I posted it with desperate heart.

If you have solved this problem or know how to do it, please let me know.

Yours sincerely,

Did you build PyTorch/Caffe2 before from source and was it working correctly?
If so, did you use the same CUDA version?
Your setup looks correct, so could you maybe clean the build and rerun it?
If that doesn’t help, could you check, if you would be able to build libtorch in a docker container?