Build PyTorch without AVX/AVX2 or CUDA for old systems

mightykatun: <p><a class="hashtag-cooked" href="/c/c/11" data-type="category" data-slug="c" data-id="11"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>C++</span></a> <a class="hashtag-cooked" href="/c/compile/41" data-type="category" data-slug="compile" data-id="41"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>torch.compile</span></a> <a class="hashtag-cooked" href="/c/deployment/14" data-type="category" data-slug="deployment" data-id="14"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>deployment</span></a><br>
Hey everyone,<br>
I’ve been trying to see how old of a device you could actually build PyTorch on, I have a dozen apple mac desktops from 2009 with intel core2 quads and would like to run an llm exo cluster on them (just for fun he thought, foolishly <img src="https://discuss.pytorch.org/images/emoji/apple/joy.png?v=12" title=":joy:" class="emoji" alt=":joy:" loading="lazy" width="20" height="20">).<br>
I wrote a short script to help make the build process repeatable, but the build process keeps failing with diverse dependencies issues and failed tests, my best attempt at a functioning set of commands is joined below.</p>
<p>The problem at hand is that those old cpus don’t even support AVX nor AVX2 (cuda is just not required by the lack of GPU), and to make exo run, you need PyTorch &gt;= 2.0.0.<br>
I have found instructions on an old post for an even older version of PyTorch <a href="https://discuss.pytorch.org/t/how-to-build-pytorch-without-avx/158408">here</a>, but this process obviously doesn’t work for 2.0 and above.<br>
I’d appreciate any input on that matter!</p>
<p>Here is my script currently, (and error log pastebin below), I’m running Ubuntu Server 24.01:</p>
<pre data-code-wrap="bash"><code class="lang-bash">VERSION=2.0.0

# Dependencies

apt install libopenblas-dev cmake -y
apt install python3-typing-extensions python3-numpy -y
apt install intel-mkl-full -y
apt install python3-pip -y
apt install python3-typing-extensions python3-numpy -y

# Download

wget https://github.com/pytorch/pytorch/archive/refs/tags/v2.0.0.tar.gz
tar -xvzf v2.0.0.tar.gz &gt;&gt; /dev/null
rm v2.0.0.tar.gz

cd pytorch-2.0.0

git submodule deinit -f .
git submodule sync --recursive
git submodule update --init --recursive

mkdir build &amp;&amp; cd build

# Are those env variables even useful??

export MKLROOT=/opt/intel/mkl
export LD_LIBRARY_PATH=$MKLROOT/lib/intel64:$LD_LIBRARY_PATH
export CMAKE_PREFIX_PATH=$MKLROOT
export BLAS=MKL
export USE_MKLDNN=OFF

# Start build

cmake -DCMAKE_BUILD_TYPE=Release \
      -DUSE_CUDA=OFF \
      -DUSE_NNPACK=OFF \
      -DUSE_MKLDNN=OFF \
      -DCMAKE_C_FLAGS="-mno-avx -mno-avx2" \
      -DCMAKE_CXX_FLAGS="-mno-avx -mno-avx2" \
      ..

make -j4
sudo make install
sudo ldconfig
</code></pre>
<p>ERROR LOG: <a href="https://pastebin.com/zuT2DKt3" rel="noopener nofollow ugc">here</a></p>