I am trying to build libtorch like so:
USE_CUDA=0 cmake -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=Release -DPYTHON_EXECUTABLE:PATH=`which python3` -DCMAKE_INSTALL_PREFIX:PATH=../pytorch-install ../pytorch &&\
USE_CUDA=0 cmake --build . --target install
However, I see that it is still building with CUDA not sure why this is…
albanD
(Alban D)
November 20, 2020, 7:16pm
2
Hi,
Why are you building with CMake directly? If you want to do a python install, you should be using setup.py
and the USE_CUDA
flag will be properly picked up in that case.
If you are trying to do a libtorch install (I am not sure what is the process supposed to be), it might be that the flag is not the same for it.
1 Like
my goal is to build a minimalist cpu build of libtorch.
I now see what you mean that I can use python to build libtorch:
libtorch (C++-only)
===================
The core of pytorch does not depend on Python. A
CMake-based build system compiles the C++ source code into a shared
object, libtorch.so.
Building libtorch using Python
------------------------------
You can use a python script/module located in tools package to build libtorch
::
cd <pytorch_root>
# Make a new folder to build in to avoid polluting the source directories
mkdir build_libtorch && cd build_libtorch
# You might need to export some required environment variables here.
Normally setup.py sets good default env variables, but you'll have to do
that manually.
This file has been truncated. show original
but I think the problem is I am not sure if I can link to through through other C++ programs.
Anyways, I will try it now.
1 Like