USE_CUDA=0 has no effect with cmake build

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 :frowning: not sure why this is…

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:

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