[libtorch] FindCUDA error when running cmake

Hi there,

I am trying to link libtorch with my project using CMakeList.txt. But cmake gives me the following error when executing find_package(Torch REQUIRED):

– Caffe2: CUDA detected: 9.0.176
– Caffe2: CUDA nvcc is: /usr/local/cuda-9.0/bin/nvcc
– Caffe2: CUDA toolkit directory: /usr/local/cuda-9.0
– Caffe2: Header version is: 9.0
CMake Error at /opt/libtorch/share/cmake/Caffe2/public/cuda.cmake:59 (message):
FindCUDA says CUDA version is (usually determined by nvcc), but the CUDA
headers say the version is 9.0. This often occurs when you set both
CUDA_HOME and CUDA_NVCC_EXECUTABLE to non-standard locations, without also
setting PATH to point to the correct nvcc. Perhaps, try re-running this
command again with PATH=/usr/local/cuda-9.0/bin:$PATH. See above log
messages for more diagnostics, and see
It's difficult to use non-standard CUDA_HOME with ccache'd nvcc · Issue #8092 · pytorch/pytorch · GitHub for more details.
Call Stack (most recent call first):
/opt/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:88 (include)
/opt/libtorch/share/cmake/Torch/TorchConfig.cmake:39 (find_package)

My system is ubuntu 18.04 and I only have CUDA 9.0 (V9.0.176) installed. /usr/local/cuda-9.0/bin is already in my PATH.

Hope to get some help here. Thanks.