/prism:install-linuxfrom prism
Builds PRISM and T-PRISM from source on Ubuntu (22.04-26.04). Covers apt dependencies, C/Prolog build with USE_NPY/USE_H5/USE_PB/PROCTYPE=mp options, PATH setup, regression tests, T-PRISM Python venv, and common build/run error fixes.
Ships in prism. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
PRISM has three layers, built in this order. The Prolog build runs the C binary, so the C part must be built and installed first.
| Layer | Source | Output in bin/ |
|---|---|---|
| C engine (links the B-Prolog static library) | src/c/ | prism_up_linux.bin (prism_mp_linux.bin for MPI) |
| Prolog system | src/prolog/ | prism.out, batch.out, mpprism.out, foc.out |
T-PRISM Python package (tprism command) | bin/tprism/ | installed with pip |
bin/prism, bin/upprism and bin/mpprism are shell scripts that start
bin/prism_*_linux.bin with bin/bp.out and the .out files, so everything
runs from bin/ once it is built.
The commands below were checked on these Ubuntu versions:
| Ubuntu | gcc | Python | HDF5 | Notes |
|---|---|---|---|---|
| 22.04 | 11 | 3.10 | 1.10 | |
| 24.04 | 13 | 3.12 | 1.10 | |
| 26.04 | 15 | 3.14 | 1.14 | the MPI build needs one extra flag (section 3) |
Options go on the make command line of the C part. The defaults are in
src/c/makefiles/Makefile.opts.gmake.
| Option | Enables | Needed for | Extra apt packages |
|---|---|---|---|
USE_NPY=1 | NumPy (.npy) output of tensors and data | T-PRISM embeddings saved as npy (e.g. exs/tensor/transitive_closure01) | none (bundled libnpy) |
USE_H5=1 | HDF5 output | T-PRISM placeholder data, which save_placeholder_goals/2,3 writes as .h5 by default (e.g. exs/tensor/mlp) | pkg-config libhdf5-dev |
USE_PB=1 | protocol buffer output (pb, pbtxt) | only when you need pb/pbtxt files (tprism itself reads JSON only) | pkg-config libprotobuf-dev protobuf-compiler |
PROCTYPE=mp | MPI version (prism_mp_linux.bin, mpprism) | parallel EM learning | libopenmpi-dev openmpi-bin |
Recommendations:
USE_NPY=1 USE_H5=1. The prism_tprism_pre_linux_ubuntu* packages are built this way.prism_linux_dev.auto.tar.gz) uses only USE_NPY=1, so the HDF5-based examples do not work with it.USE_PB=1 makes the binary depend on one exact libprotobuf version, so enable it only if you need pb or pbtxt output (see section 5).sudo apt-get update
sudo apt-get install -y g++ make git # always
sudo apt-get install -y pkg-config libhdf5-dev # USE_H5=1
sudo apt-get install -y pkg-config libprotobuf-dev protobuf-compiler # USE_PB=1
sudo apt-get install -y libopenmpi-dev openmpi-bin # PROCTYPE=mp
In a Docker container you are root, so drop sudo and set
DEBIAN_FRONTEND=noninteractive.
From the top of the repository:
git clone https://github.com/prismplp/prism.git && cd prism # if not cloned yet
cd src/c
make -f Makefile.gmake -j USE_NPY=1 USE_H5=1
make -f Makefile.gmake USE_NPY=1 USE_H5=1 install # copies prism_up_linux.bin into bin/
cd ../prolog
make
make install # copies the .out files into bin/
cd ../..
export PATH=$PWD/bin:$PATH # add to ~/.bashrc to keep it
install step.make -f Makefile.gmake clean in src/c before changing the options. make does not track the flags, so objects compiled with other options are kept silently. For example, adding USE_H5=1 without clean still gives a binary without HDF5 support.cd src/c
make -f Makefile.gmake clean
make -f Makefile.gmake -j PROCTYPE=mp USE_NPY=1
make -f Makefile.gmake PROCTYPE=mp USE_NPY=1 install # bin/prism_mp_linux.bin
make -f Makefile.gmake clean # before building the uniprocessor version again
Notes on the MPI build:
pc_mp_abort_0 in core/error.c. Build with CC="mpicc -Wno-error=implicit-function-declaration" added to both make commands.mpprism runs mpirun. The number of processes comes from NPROCS (default 4), and a machine file from MACHINES. Extra mpirun options go in PRISM_MPIRUN_OPTS.cd testing && sh test_mp.sh, which uses NPROCS=2.OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 there.src/c/CMakeLists.txt) fails at link time on Ubuntu 24.04 (cannot find -lhdf5_cpp).cd exs/base && upprism hmm 50 && cd ../.. # learns an HMM; prints "Final log likelihood: ..."
cd testing && sh test.sh && cd .. # 23 programs; exits non-zero on the first failure
test.sh must run in testing/. It runs every testing/programs/*.psm
(expected to succeed) and every testing/irregular_programs/*.psm (expected to
fail). prism starts the interactive mode (Ctrl+D quits).
To check that the options are compiled in, look for the error messages of the disabled formats in the binary:
strings bin/prism_up_linux.bin | grep -E "(hdf5|npy|Pb) format is not implemented"
# each line printed = a format that is NOT enabled
USE_PB=1) and the protobuf versionC++ code generated by protoc compiles only against the same libprotobuf
version. The bundled src/c/external/expl.pb.cc/.h are generated by protoc
3.21.12, the libprotobuf of Ubuntu 24.04 and 26.04.
| Ubuntu | libprotobuf (apt) | before make ... USE_PB=1 |
|---|---|---|
| 22.04 | 3.12.4 | run sh src/c/external/generate.sh (regenerates with the installed protoc) |
| 24.04, 26.04 | 3.21.12 | nothing |
A version mismatch stops the build with one of these errors:
#error This file was generated by a newer version of protoc ...#error This file was generated by an older version of protoc ...#error "Protobuf C++ gencode is built with an incompatible version of"The Makefiles never regenerate the code, so that builds work without protoc.
Do not commit code regenerated by another protoc version.
doc/devel/protoc.txt has the full version policy.
T-PRISM needs Python >= 3.10, PyTorch, NumPy, h5py, scikit-learn and protobuf.
bin/requirements.txt requires protobuf >= 4.21.12, or >= 5.27.0 on Python 3.14.
pip install of T-PRISM does not install these dependencies, so install them first.
On Ubuntu 24.04 and later, pip refuses to install into the system Python
(externally-managed-environment), so use a venv or conda.
sudo apt-get install -y python3-venv
python3 -m venv ~/venv/tprism && . ~/venv/tprism/bin/activate
pip install torch --index-url https://download.pytorch.org/whl/cpu # CPU; for CUDA see https://pytorch.org/
pip install numpy h5py scikit-learn -r bin/requirements.txt
pip install ./bin # this checkout; or "git+https://github.com/prismplp/prism.git#egg=t-prism&subdirectory=bin"
Optional packages:
pandas: the MNIST examples need it, because fetch_openml of scikit-learn requires it.networkx pyvis ipython: for tprism.plot.geotorch: for constrained tensors. Install it with pip install git+https://github.com/Lezcano/geotorch/.Check the environment with two examples:
cd exs/tensor/distmult_sample01 && sh run.sh && cd - # JSON only, a few seconds
cd exs/tensor/mlp && sh run.sh && cd - # needs USE_H5=1 and pandas; downloads MNIST
About the MNIST example (exs/tensor/mlp):
accuracy: N / 10000. With the default settings N is about 8900, while an untrained model gives about 1000.run.sh does not stop on errors, so look at the whole log, not only the exit status.OpenMLError: Dataset with data_id 554 not found). Rerun python build_dataset.py in the mnist/ subdirectory until it succeeds.The binary packages contain the repository and a built bin/. Extract one and
add prism/bin to PATH. The binary needs a glibc at least as new as the
Ubuntu it was built on, plus the HDF5 runtime libraries if it was built with
USE_H5=1.
| Package | Built on | Runs on | apt runtime packages |
|---|---|---|---|
prism_tprism_pre_linux_ubuntu22.tar.gz | 22.04 | 22.04, 24.04 | 22.04: libhdf5-103-1 libhdf5-cpp-103-1; 24.04: libhdf5-103-1t64 libhdf5-cpp-103-1t64 |
prism_tprism_pre_linux_ubuntu24.tar.gz | 24.04 | 24.04 | libhdf5-103-1t64 libhdf5-cpp-103-1t64 |
prism_linux_dev.auto.tar.gz (CI, USE_NPY=1 only) | latest Ubuntu | that version and later | none |
Neither ubuntu22 nor ubuntu24 runs on Ubuntu 26.04. Its HDF5 is 1.14
(libhdf5_serial.so.310, packages libhdf5-310 libhdf5-cpp-310), and the
1.10 libraries (.so.103) are not available there. On 26.04, build from
source, or make a package on 26.04.
To make such a package, follow tools/init_package.sh in a clean container of
the target Ubuntu (e.g. docker run --rm -it -v $PWD:/out ubuntu:22.04):
USE_NPY=1 USE_H5=1.cd tools && sh init_package.sh, then tar czf /out/prism_tprism_pre_linux_ubuntu22.tar.gz prism/.Notes on packaging:
init_package.sh clones GitHub master into tools/prism and copies the binaries from bin/. Push first, so that the packaged source matches the binaries.cp: cannot stat errors for the MPI, macOS and Windows binaries are expected.| Symptom | Cause and fix |
|---|---|
Sorry, PRISM doesn't support this system. (prism) or Sorry, but PRISM doesn't support this system. (upprism, mpprism) | bin/prism_up_linux.bin is missing (for mpprism, bin/prism_mp_linux.bin): build and install the C part (section 3). |
implicit declaration of function 'pc_mp_abort_0' (MPI build, gcc >= 14) | Add CC="mpicc -Wno-error=implicit-function-declaration" (section 3). |
mpirun has detected an attempt to run as root | Set OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1, or run as a normal user. |
Can't execute ../../bin/prism_up_linux.bin while building src/prolog | The C part is not installed yet. Run make -f Makefile.gmake install in src/c first. |
[ERROR] hdf5 format is not implemented (please compile prism with the USE_H5 option) | Rebuild the C part with USE_H5=1 (after make clean). |
[ERROR] npy format is not implemented ... | Rebuild with USE_NPY=1 (after make clean). |
[ERROR] Pb format is not implemented ..., or Unknown format. when saving pb/pbtxt | Rebuild with USE_PB=1 (section 5). |
#error ... generated by a newer/older version of protoc, Protobuf C++ gencode is built with an incompatible version | libprotobuf version differs from the generated code: sh src/c/external/generate.sh (section 5). |
cannot use keyword 'false' as enumeration constant (gcc >= 15) | Old checkout. The current Makefile compiles C with -std=gnu11. Don't override CFLAGS/CC without it. |
C++ versions less than C++17 are not supported (abseil, newer libprotobuf) | Old checkout. The current Makefile uses -std=c++17. |
libhdf5_serial.so.103 => not found / error while loading shared libraries | Install the HDF5 runtime packages (section 7). |
version `GLIBC_2.38' not found | The binary was built on a newer Ubuntu: use the package for your Ubuntu or build from source. |
error: externally-managed-environment from pip | Use a venv or conda (section 6). |
TypeError: Descriptors cannot be created directly. | Old bin/tprism/expl_pb2.py with protobuf >= 4.21. Update the checkout (current code works with protobuf >= 4.21.12). |
TypeError: Metaclasses with custom tp_new are not supported. (Python 3.14) | protobuf < 5.27 on Python 3.14: pip install -U protobuf. |
ImportError: fetch_openml requires pandas. | pip install pandas. |
unknown loss function: ..., then RuntimeError: output/loss is None in training | Wrong --sgd_loss. Loss arguments are terms, e.g. ce(0.1) or 'ce_pl($placeholder2$)'. Single-quote them in the shell so $... is not expanded. |
To reproduce a user's environment without touching the host, run the steps in a container of the same Ubuntu version. Mount the repository read-only and build in a copy:
docker run --rm -v "$PWD":/repo:ro ubuntu:24.04 bash -c '
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq && apt-get install -y -qq g++ make pkg-config libhdf5-dev >/dev/null
cp -r /repo /tmp/prism && cd /tmp/prism
{ (cd src/c && make -f Makefile.gmake -j USE_NPY=1 USE_H5=1 && make -f Makefile.gmake USE_NPY=1 USE_H5=1 install) &&
(cd src/prolog && make && make install); } >/tmp/build.log 2>&1 || { tail -20 /tmp/build.log; exit 1; }
export PATH=$PWD/bin:$PATH
cd testing && sh test.sh >/tmp/test.log 2>&1 && echo "build and test.sh: OK" || { tail -5 /tmp/test.log; exit 1; }'
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
prism, t-prism, ubuntu-build, source-compilation, prolog-build
6 skills in this plugin
/install-mingwBuild and verify PRISM and bp4prism on Windows with native MinGW-w64, including optional 32bit and 64bit MS-MPI builds, without tools/mingw helper scripts./prism-programmingHow to write, run, debug and learn parameters for PRISM programs (probabilistic Prolog on B-Prolog, .psm files, prismplp/prism), with the differences from ProbLog and plain Prolog spelled out, plus two recipes - turning a deterministic Prolog rule base into a PRISM model whose default reproduces the rules and is then refined by EM, and driving a .psm from shell scripts, other languages and pipelines (prism_main/1 modes, parseable output, exit codes). Use it whenever the user mentions PRISM, .psm, msw/2, values/2, upprism, learn/1, save_sw/restore_sw, viterbif, hindsight, probf, graphical EM, 確率的推論 or probabilistic prolog, asks for an HMM, PCFG, Bayesian network or other model in PRISM, translates ProbLog or Prolog into PRISM, or debugs an msw, negation or learn error. Read it before writing any PRISM code, because ProbLog and Prolog intuitions (shared random variables, negation) silently give wrong answers. For T-PRISM use tprism-programming, for Python programming-pyprism and programming-prism-ds./programming-prism-dsData science with PRISM from Python (pyprism). Turn tabular data (pandas DataFrames, CSV, scikit-learn datasets) into discretized PRISM facts with pyprism.dataset. Write generative models for it (independent features, naive Bayes classifiers, latent-class clustering). Learn parameters by EM, MAP or variational Bayes, read them as pandas DataFrames (pyprism.df.sw2df) and plot them. Predict and evaluate on test data (viterbig, prob, hindsight), handle missing values, and compare models by BIC. Use this skill whenever the user analyses data with PRISM or pyprism, follows the PRISM data-science tutorial (PRISM_DS_tutorial, "PRISMでデータ分析", "データサイエンス", "ナイーブベイズ", "離散化"), or mentions load_discrete_diabetes, load_discrete_california_housing, preprocess, sw2df, plot_dist or get_conditional_dist2. Builds on programming-pyprism (installation, PrismEngine, per-query processes) and prism-programming (how values/msw models work)./programming-pyprismInstall PyPRISM (the pyprism package, the Python interface of PRISM, prismplp/pyprism) so that it matches the Python environment (Google Colab, venv or conda on Linux, Jupyter), and use its PrismEngine to run Prolog and PRISM programs and queries from Python (set_db, query with out/findall/find_n, prob, sample, learn, save_sw/restore_sw, parsing the results). Use this skill whenever the user mentions pyprism, PyPRISM, PrismEngine, engine.query or engine.set_db, runs PRISM or Prolog from Python or a notebook, follows the Prolog or PRISM tutorials on Colab ("PythonからPRISM", "PythonからProlog", "pyprismのインストール"), or gets a pyprism result like (None, 'error'). For writing the probabilistic models themselves also use prism-programming, and for data-science workflows (pyprism.dataset, sw2df, prediction) use programming-prism-ds./tprism-programmingHow to write, build and train T-PRISM (Tensorized PRISM, prismplp/prism) programs, where Prolog atoms denote tensors combined by einsum and trained with PyTorch. Covers .psm programs (tensor/2, tensor_atom/2, operator/1, subgoal/2, get/2, placeholders, embeddings, save_expl_graph), `tprism train/test`, and the Python API (load_explanation_graph, TprismModel fit/pred, custom operators and losses) in Jupyter or Colab, also via PyPRISM's PrismEngine. Use it whenever the user mentions T-PRISM, TPRISM, tprism, TprismModel or T_PRISM_tutorial, or wants tensor decomposition, DistMult, an MLP or CNN, MNIST addition, a Markov chain or transitive closure written in Prolog with tensors, or to port a Prolog, ProbLog or PRISM model to T-PRISM. Read it before writing T-PRISM code, because its semantics (sum over Prolog solutions, einsum over index names, operator/1 scope, compile time vs run time) differ from Prolog, ProbLog and classic PRISM, and mistakes are silent. For classic PRISM (msw/values) use prism-programming.npx claudepluginhub prismplp/prism --plugin prismOther plugins' skills for the same job