I’ve gone into the same question, and here is how I did (tested with AGX Orin and L4T R35.1).
Be sure you have at least 5GB of free space in rootfs (/) for install and 20GB for building.
Be aware that it may take more than one hour to build on AGX Orin with boosted clocks, may take a night on Nano.
sudo jetson_clocks
sudo apt update
sudo apt install -y build-essential pkg-config
sudo apt install -y meson ninja-build
cd <path_to_a_drive_where_you_have_more_than_20GB>
mkdir -p Halide-top
cd Halide-top
1. Build cmake-3.25.1
Be sure that PATH shows /usr/local/bin before /usr/bin.
sudo apt install -y cmake libssl-dev curl
# For Qt GUI
sudo apt install -y qt5-default
mkdir cmake-3.25.1
cd cmake-3.25.1
#sudo apt install -y libssl-dev
mkdir -p Src
cd Src
wget -c --show-progress https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1.tar.gz
tar xvf cmake-3.25.1.tar.gz
cd ..
mkdir -p cmake-3.25.1-build && cd cmake-3.25.1-build
#cmake -DCMAKE_USE_OPENSSL=OFF ../cmake-3.25.1
# If you want to build cmake-gui against Qt5
cmake -DCMAKE_-DBUILD_QtDialog=ON -DQT_QMAKE_EXECUTABLE=/usr/lib/qt5/bin/qmake ../Src/cmake-3.25.1
make -j $(nproc)
#make test
# This would install into /usr/local
sudo make install
# This should show version 3.25.1
cmake --version
cd ../..
2. Build LLVM-16
Here using today’s main branch that is pre-release 16.0.0.
Note that many other dependencies not listed here may be required, you would find these from LLVM docs and install with apt.
mkdir llvm-16-for-Halide
cd llvm-16-for-Halide
# Some dependencies... not sure if these are all relevant or mandatory...
sudo apt install -y libtinfo-dev libltdl-dev zlib1g-dev
sudo apt install -y libhwloc-dev libedit-dev
sudo apt install -y libffi-dev libgomp1 libopenmpi-dev
# Get LLVM project sources - Today main branch for llvm-16
git clone --recursive https://github.com/llvm/llvm-project.git
mkdir llvm-project-build
cd llvm-project-build
# Here configuring openmp nvptx for Orin (sm_87), you would adjust if using another Jetson (53 for Nano/TX1, 62 for TX2, 72 for Xavier...)
/usr/local/bin/cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/llvm-16 -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;openmp" -DLLVM_TARGETS_TO_BUILD="AArch64;NVPTX" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="SPIRV" -DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_87 -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_FFI=ON -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_BUILD_32_BITS=OFF -DLLVM_BUILD_DOCS=OFF ../llvm-project/llvm
Now there is a bug in cmake install files where it would fail to install docs when docs are not built.
Edit file cmake_install.cmake and comment out (may be line 87 or around) such as:
#include("<path-to-your-build-directory>/docs/cmake_install.cmake")
Once done, build and install:
# This will take some time
make -j$(nproc)
# Tests would be built if not yet done before running
#make check-all
#make check-llvm
# Or just run target tests with llvm-lit script already available
#./bin/llvm-lit ../llvm-project/llvm/test/CodeGen/AArch64
#./bin/llvm-lit ../llvm-project/llvm/test/CodeGen/NVPTX
#./bin/llvm-lit ../llvm-project/llvm/test/CodeGen/SPIRV
sudo make install
cd ../..
This has installed llvm-16 into /usr/local/llvm-16, so adjust your environment for using it:
export PATH=/usr/local/llvm-16/bin:$PATH
export LD_LIBRARY_PATH=usr/local/llvm-16/lib:$LD_LIBRARY_PATH
You may add the above lines at the end of your user’s .bashrc if you don’t want to set manually set these next times.
# This should show clang version 16.0.0
clang++ --version
3. Build Halide
sudo apt install -y pip3 meson ninja-build
sudo pip3 install virtualenv
mkdir Halide
cd Halide
# Get sources:
git clone --recursive https://github.com/halide/Halide.git
# setup python requirements (You may do that in a virtual env, see Halide/README_python.md)
virtualenv --system-site-packages halide_venv
source ./halide_venv/bin/activate
python3 -m pip install -U setuptools wheel testresources
python3 -m pip install -r Halide/requirements.txt
mkdir build-release
cd build-release
LLVM_ROOT=/usr/local/llvm-16
# Configure. Here disabling tutorials beacuse it fails without Windows.
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/Halide -DLLVM_DIR=$LLVM_ROOT/lib/cmake/llvm -DTARGET_D3D12COMPUTE=OFF -DTARGET_METAL=OFF -DTARGET_SPIRV=ON -DWITH_TUTORIALS=OFF -DWITH_PYTHON_BINDINGS=ON ../Halide
cmake --build .
# Note this shows 2 Warnings:
#[3026/3334] Generating alias_Mullapudi2016.h, alias_Mullapudi2016.o
#Warning: Insufficient parallelism for output
#[3054/3334] Generating autograd_grad.h, autograd_grad.o
#Warning: Insufficient parallelism for _grad_loss_output_lut_wrt_lut_indices
#[3334/3334] Linking CXX executable util/HalideTraceDump
sudo cmake --install .
cd ..
Adjust the environment again:
export PATH=/usr/local/Halide/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/Halide/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/usr/local/Halide/lib/python3/site-packages:$PYTHONPATH
4. Try the Halide tutorials
We have disabled these so these are not installed, but it is still possible to manually install and run these:
# should still be in Halide-top directory
mkdir tutorial
cd tutorial
cp -r ../Halide/tutorial/images .
cp -r ../Halide/tutorial/figures .
cp ../Halide/tutorial/*.h .
cp ../Halide/tutorial/*.cpp .
# You would be able to build lessons with the commands in the comments in code of each lesson, for example:
g++ -std=c++17 -I/usr/local/Halide/include -I/usr/local/Halide/share/tools -I. lesson_01_basics.cpp -L/usr/local/Halide/lib -lHalide -lpng -ljpeg -lpthread -ldl -o lesson_01_basics
./lesson_01_basics
Success!
...
5. Try from python:
python3
import halide
...