Getting Error in CMake Libtorch

I’m getting CMake error while doing cmake -DCMAKE_PREFIX_PATH=…/…/libtorch … . Yesterday I followed the same step, which is on Pytorch. I’m able to build it successfully on my laptop, but when I’m doing the same I’m getting an error like

I looked all the answer which are relevant to this, but all that didn’t let me to the conclusion. Can someone help me in this regard?
Thank you.

Have you checked and made sure that there is a libtorch installation at ../../libtorch? Also another thing to try is to remove the ~/example-app/build folder, recreate it again and then rerun the steps.

Hi Will,
I tried the above steps mentioned by you, but it is throwing same error. What to do? I have downloaded the libtorch and extracted it in specified directory.

Do you download the right version of libtorch? I download a windows version on my linux machine last time.

Hi Kevin,
Yes i did. I also tried without CUDA version also, I’m getting the same error.

@ritesh_gupta Could you provide the result of ls ~/libtorch on your machine?


Wouln’t you need to point to the subdir containing the cmake files (share/cmake)?

Sorry, I didn’t get you?

I think error could be because of cuda. As same program without CUDA Libtorch runs perfectly well(left terminal), whereas with CUDA Libtorch throws error(right terminal). Any help would be welcome.


1 Like

Thanks for debugging further. I think the answer to the previous problem is that we should use cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch .. instead of cmake -DCMAKE_PREFIX_PATH=relative/path/to/libtorch ... Putting it here so that other users could see the solution.

Do you have the in the directory it’s looking in? Or one nearby (like cuda-10)?

No, I don’t have that file in both places.

Thanks Will, But the screenshot I posted has an absolute path, not a relative path. Also any idea on how to correct the library error? I tried giving

by following the command given at but to no luck.

@ritesh_gupta Did you make sure that CUDA is correctly installed on your machine?

@yf225 I’m using DGX server which already has preinstalled CUDA. I can run the pytorch model on GPU. So I think so the installation of CUDA is an issue out here.

Does the link below help you? I think you need to check to make sure that /usr/local/cuda/ or /usr/local/cuda-10.0 you are using.