Thank you for your interest in contributing to PostgresML! We are an open source, MIT licensed project, and we welcome all contributions, including bug fixes, features, documentation, typo fixes, and Github stars.

Our project consists of three (3) applications:

  1. Postgres extension (pgml-extension)
  2. Dashboard web app (pgml-dashboard)
  3. Documentation (pgml-docs)

The development environment for each differs slightly, but overall we use Python, Rust, and PostgreSQL, so as long as you have all of those installed, the setup should be straight forward.

Build Dependencies

  1. Install the latest Rust compiler from

  2. Install a modern version of CMake.

  3. Install PostgreSQL development headers and other dependencies:

    export POSTGRES_VERSION=15
    sudo apt-get update && \
    sudo apt-get install -y \
        postgresql-server-dev-${POSTGRES_VERSION} \
        bison \
        build-essential \
        clang \
        cmake \
        flex \
        libclang-dev \
        libopenblas-dev \
        libpython3-dev \
        libreadline-dev \
        libssl-dev \
        pkg-config \
  4. Install the Python dependencies

    If your system comes with Python 3.6 or lower, you'll need to install libpython3.7-dev or higher. You can get it from ppa:deadsnakes/ppa:

    sudo add-apt-repository ppa:deadsnakes/ppa && \
    sudo apt update && sudo apt install -y libpython3.7-dev

    With Python 3.7+ installed, install the package dependencies

    sudo pip3 install xgboost lightgbm scikit-learn
  5. Clone our git repository:

    git clone && \
    cd postgresml && \
    git submodule update --init --recursive && \

Postgres extension

PostgresML is a Rust extension written with tcdi/pgx crate. Local development therefore requires the latest Rust compiler and PostgreSQL development headers and libraries.

The extension code is located in:

cd pgml-extension/

You'll need to install basic dependencies

Once there, you can initialize pgx and get going:

Pgx command line and environments

cargo install cargo-pgx --version "0.7.1" && \
cargo pgx init # This will take a few minutes

Update postgresql.conf

pgx uses Postgres 15 by default. Since pgml is using shared memory, you need to add it to shared_preload_libraries in postgresql.conf which, for pgx, is located in ~/.pgx/data-15/postgresql.conf.

shared_preload_libraries = 'pgml'     # (change requires restart)

Run the unit tests

cargo pgx test

Run the integration tests:

cargo pgx run --release
psql -h localhost -p 28813 -d pgml -f tests/test.sql -P pager

Run an interactive psql session

cargo pgx run

Create the extension in your database:


That's it, PostgresML is ready. You can validate the installation by running:

SELECT pgml.version();

postgres=# select pgml.version();
(1 row)

Basic extension usage:

SELECT * FROM pgml.load_dataset('diabetes');
SELECT * FROM pgml.train('Project name', 'regression', 'pgml.diabetes', 'target', 'xgboost');
SELECT target, pgml.predict('Project name', ARRAY[age, sex, bmi, bp, s1, s2, s3, s4, s5, s6]) FROM pgml.diabetes LIMIT 10;

By default, the extension is built without CUDA support for XGBoost and LightGBM. You'll need to install CUDA locally to build and enable the cuda feature for cargo. CUDA can be downloaded here.

CUDACXX=/usr/local/cuda/bin/nvcc cargo pgx run --release --features pg15,python,cuda 

If you ever want to reset the environment, simply spin up the database with cargo pgx run and drop the extension and metadata tables:



This requires Docker. Once Docker is installed, you can run:


which will produce a .deb file in the current directory (this will take about 20 minutes). The deb file can be installed with apt-get, for example:

apt-get install ./postgresql-pgml-12_0.0.4-ubuntu20.04-amd64.deb

which will take care of installing its dependencies as well. Make sure to run this as root and not with sudo.

Run the dashboard

The dashboard is a web app that can be run against any Postgres database with the extension installed. There is a Dockerfile included with the source code if you wish to run it as a container.

The dashboard requires a Postgres database with the pgml-extension to generate the core schema. See that subproject for developer setup.

We develop and test this web application on Linux, OS X, and Windows using WSL2.

Basic installation can be achieved with:

  1. Clone the repo (if you haven't already for the extension):
  cd postgresml/pgml-dashboard
  1. Set the DATABASE_URL environment variable, for example to a running interactive cargo pgx run session started previously:
export DATABASE_URL=postgres://localhost:28815/pgml
  1. Run migrations
sqlx migrate run
  1. Run tests:
cargo test
  1. Incremental and automatic compilation for development cycles is supported with:
cargo watch --exec run

The dashboard can be packaged for distribution. You'll need to copy the static files along with the target/release directory to your server.

Documentation app

The documentation app (you're using it right now) is using MkDocs.

cd pgml-docs/

Once there, you can set up a virtual environment and get going:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python -m mkdocs serve


We are a cross-platform team, some of us use WSL and some use Linux or Mac OS. Keeping that in mind, it's good to use common line endings for all files to avoid production errors, e.g. broken Bash scripts.

The project is presently using Unix line endings.

Have Questions?

Join our Discord and ask us anything! We're friendly and would love to talk about PostgresML.

Try It Out

Try PostresML using our free managed cloud. It comes with 5 GiB of space and plenty of datasets to get you started.

Powered by PostgresML Logo PostgresML