You can build Tachyon with this guide. The instructions below will help you set up your environment, install necessary dependencies, and compile your projects efficiently. Follow along to start building with confidence.
Follow the installation instructions for Bazel here.
sudo apt install libgmp-dev libomp-dev zip
brew install gmp
-
Install Python. Python v3.10.12 is recommended.
-
If you are using pyenv, don't forget to add an option
--enable-shared
.CONFIGURE_OPTS=--enable-shared pyenv install <version>
If you want to print a benchmark plot, you need to install matplotlib. See here for more details.
pip install matplotlib
NOTE:
-
To build
mac_logging
in MacOS, you need to install objc, which can be done by installing XCode. -
MacOS v14.0.0 or later is recommended. In certain versions of MacOS (prior to v13.5.1), a bug related to incorrect
BigInt
divide operations has been detected in the field generator when using the optimized build (-c opt
). This issue will be fixed as soon as possible.
bazel build //...
bazel test //...
opt
: Default optimized build optiondbg
: Build with debug infofastbuild
: Fast build option
bazel build --config dbg //...
-
--config cuda
: Enable cuda backend.bazel build --config cuda //...
-
--config rocm
: Enable rocm backend.bazel build --config rocm //...
NOTE: The rocm
option is not recommended for current use because it is not being tested yet.
Build options can be preset in .bazelrc.user
for your convenience, eliminating the need to specify them on the command line.
For example:
# .bazelrc.user
build --config dbg
bazel build //...
# With the preset options in .bazelrc.user, this is the same as:
# bazel build --config dbg //...
Tachyon can be built in your own Bazel project with the following two simple steps.
First, obtain the Tachyon code from a specific commit hash and get a SHA256 value from the fetched code through these commands:
wget https://github.com/kroma-network/tachyon/archive/e02feac98608a6bb1efc75df07237f702db7cce7.tar.gz
shasum -a 256 e02feac98608a6bb1efc75df07237f702db7cce7.tar.gz
Second, input the shasum output into your WORKSPACE
file as the sha256
argument like shown below:
# WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "kroma_network_tachyon",
sha256 = "e3bfefb20bcb425a5169c46cf0bd4dacbdeaceab94b144a3d5fa4214d9e974d2",
strip_prefix = "tachyon-e02feac98608a6bb1efc75df07237f702db7cce7",
urls = ["https://github.com/kroma-network/tachyon/archive/e02feac98608a6bb1efc75df07237f702db7cce7.tar.gz"],
)
There are two ways to install the Tachyon package. While it is recommended to install the package from the prebuilt binaries, building the package from the source is also viable if needed.
curl -LO https://github.com/kroma-network/tachyon/releases/download/v0.4.0/libtachyon_0.4.0_amd64.deb
curl -LO https://github.com/kroma-network/tachyon/releases/download/v0.4.0/libtachyon-dev_0.4.0_amd64.deb
sudo dpkg -i libtachyon_0.4.0_amd64.deb
sudo dpkg -i libtachyon-dev_0.4.0_amd64.deb
Build a Debian package with the supported scheme (only halo2 for now) and the options you want.
To build the Halo2 Debian package, the has_openmp
option is recommended. Run the following commands:
bazel build --config opt --//:c_shared_object //scripts/packages/debian/runtime:debian
bazel build --config opt --//:c_shared_object //scripts/packages/debian/dev:debian
sudo dpkg -i bazel-bin/scripts/packages/debian/runtime/libtachyon_0.4.0_amd64.deb
sudo dpkg -i bazel-bin/scripts/packages/debian/dev/libtachyon-dev_0.4.0_amd64.deb
Please add this line to your .bazelrc.user
.
build --spawn_strategy=local
As you can see in .bazelrc, we don't enable all of the build and test targets. To enable additional targets, you may add customized --build_tag_filters
and --test_tag_filters
to your .bazelrc.user
file.
For example, add the following to .bazelrc.user
to build rust on linux:
build --build_tag_filters -objc,-cuda
Since the current toolchain is using the nightly channel, the following build flag is needed. Add this to your .bazelrc.user
.
build --@rules_rust//rust/toolchain/channel=nightly
Since scale-info needs a CARGO
environment variable, add this to your .bazelrc.user
.
build --action_env=CARGO=<path to cargo>
ModuleNotFoundError
may occur in certain python versions (v3.11.6). Python v3.10.12 is recommended.
If you are using Ubuntu 20.04, update your g++ version. The default g++-9
does not work.
sudo apt install g++-10
export CC=/usr/bin/gcc-10
export CXX=/usr/bin/g++-10
export GCC_HOST_COMPILER_PATH=/usr/bin/gcc-10
To utilize features like always_inline,
you'll need clang++ at version 15 or higher. By default, Ubuntu 22.04 installs clang-14
via apt install clang
,
so you'll need to manually install a newer version of clang and update openmp
accordingly.
First, install clang-15
and the appropriate OpenMP libraries:
sudo apt install clang-15 libomp5-15 libomp-15-dev
Next, update CC
and CXX
to point to the newly installed clang-15
and clang++-15
:
export CC=/usr/bin/clang-15
export CXX=/usr/bin/clang++-15
Make sure CC
and CXX
are properly updated to clang-15
and clang++-15
.
These commands ensure that your build environment uses clang version 15 for compilation.
You may run into the following problem:
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: linking with `external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc` failed: exit status: 127
...
= note: /usr/bin/env: 'python': No such file or directory
If you install python
through Anaconda, please include these lines in your .bazelc.user
.
build:cuda --action_env=PATH=/opt/conda/bin
build:cuda --host_action_env=PATH=/opt/conda/bin
Otherwise, install python3
and make python
point to it.
sudo apt install python3
sudo apt install python-is-python3
Additionally, please include these lines in your .bazelc.user
.
build:cuda --action_env=PATH=/usr/bin:/usr/local/bin
build:cuda --host_action_env=PATH=/usr/bin:/usr/local/bin
Update CUDA Compute Capabilities
You may run into the following problem:
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
nvcc fatal : Unsupported gpu architecture 'compute_35'
To solve this, please include these lines in your .bazelc.user
.
build:cuda --action_env=TACHYON_CUDA_COMPUTE_CAPABILITIES="compute_52"
Doxygen generates C API documents (tachyon_api_docs.zip
) in the binary directory (bazel-bin/docs/doxygen/
). Currently this feature is available only on Linux.
bazel build //docs/doxygen:generate_docs &&
unzip -o bazel-bin/docs/doxygen/tachyon_api_docs.zip &&
google-chrome bazel-bin/docs/doxygen/html/index.html
# generate HTML files and open on Chrome browser.
You may encounter an illegal instruction error when running unit tests. Although the exact cause is not yet known, thanks to @zkbitcoin, we discovered that this issue is related to ffiasm. Temporarily disabling assembly-optimized prime field can resolve this problem.
bazel build --//:has_asm_prime_field=false //...
Tachyon utilizes Perfetto for low-overhead profiling. You can visualize the generated trace by
uploading it to the Perfetto Trace Viewer. Typically, our traces are generated in the /tmp
directory with a perfetto-trace
extension.
By default, Tachyon uses GNU OpenMP (GNU libgomp
) for parallel computation. On Intel platforms, Intel OpenMP Runtime Library (libiomp
) provides OpenMP API specification support. It sometimes brings more performance benefits compared to libgomp
.
You can install libomp
by following the instructions.
To link libomp
, you need to add an additional flag --//:has_intel_openmp
.
bazel build --//:has_openmp --//:has_intel_openmp //...
See also PyTorch Recipes/Performance Tuning Guide/Intel OpenMP Library.