|
1 | 1 | #postgresml-docker |
2 | | -Run PostgresML + goodies in one command |
| 2 | + |
| 3 | +Run[PostgresML](https://postgresml.org),[TimescaleDB]() and[pgAdmin](https://www.pgadmin.org) in one command. This repository contains a`docker-compose` file to run a PostgresML database with TimescaleDB and a PgAdmin instance. The stack is configured to use the[NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) to enable GPU support for the PostgresML database. Additionally there are bulgarian dictionaries that provide full text search support for the Bulgarian language that can be spicy combined with the functionality that PostgresML provides to achieve wonderful stuff. |
| 4 | + |
| 5 | +**`TimescaleDB currently is not included in the stack. It will be added in the future.`** |
| 6 | + |
| 7 | +##Table of Contents |
| 8 | + |
| 9 | +-[Requirements](#requirements) |
| 10 | +-[Usage](#usage) |
| 11 | +-[System Requirements](#system-requirements) |
| 12 | +-[Cleanup](#cleanup) |
| 13 | + |
| 14 | +##Requirements |
| 15 | + |
| 16 | +-[Nvidia Cuda](https://developer.nvidia.com/cuda-downloads) |
| 17 | + |
| 18 | +-[Nvidia Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) |
| 19 | + |
| 20 | +Install the NVIDIA Container Toolkit on Ubuntu 22.04 |
| 21 | + |
| 22 | +```shell |
| 23 | +curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey| sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \ |
| 24 | +&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list| \ |
| 25 | + sed's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g'| \ |
| 26 | + sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list |
| 27 | + |
| 28 | +sudo apt-get update |
| 29 | +sudo apt-get install -y nvidia-container-toolkit |
| 30 | +``` |
| 31 | + |
| 32 | +##Usage |
| 33 | + |
| 34 | +```shell |
| 35 | +git clone https://github.com/athennamind/postgresml-docker.git |
| 36 | +cd postgresml-docker |
| 37 | +``` |
| 38 | + |
| 39 | +Before running the containers, take a look at the`.env` file and adjust the values to your needs. By default the stack is configured to use all available GPUs as specified in`NVIDIA_VISIBLE_DEVICES`. If you have a single GPU, you can leave the default value. For multiple GPUs please refer to the[Docker Documentation](https://docs.docker.com/compose/gpu-support/) to pin specific GPUs. |
| 40 | + |
| 41 | +```shell |
| 42 | +vim .env |
| 43 | +# .......... |
| 44 | +docker compose up -d |
| 45 | +# wait for the containers to start |
| 46 | +docker compose logs -f |
| 47 | +``` |
| 48 | + |
| 49 | +- Validate that we are all good |
| 50 | + |
| 51 | +```shell |
| 52 | +dockerexec -it pgml psql -U postgres -d pgml -c"SELECT pgml.xgboost_version();" |
| 53 | + |
| 54 | + xgboost_version |
| 55 | +----------------- |
| 56 | + 1.62 |
| 57 | +(1 row) |
| 58 | +``` |
| 59 | + |
| 60 | +- Open your browser and navigate to`http://localhost:8000` to access the PostgresML dashboard/ui/whatever. |
| 61 | +- Open your browser and navigate to`http://localhost:8001` to access the PgAdmin instance. |
| 62 | + |
| 63 | +If you want to tweak the postgres config, do by editing the`configs/pgml/postgressql.conf` file. Do not forget to restart the compose after. |
| 64 | + |
| 65 | +##System Requirements |
| 66 | + |
| 67 | +This compose was used on the following system: |
| 68 | + |
| 69 | +- Ubuntu 22.04 |
| 70 | +- Docker version 25.0.4, build 1a576c5 |
| 71 | +- 16GB of RAM |
| 72 | +- 8 CPU cores |
| 73 | +- 2x NVIDIA RTX 3090 |
| 74 | +- 1TB Local SSD Storage |
| 75 | + |
| 76 | +Please always consider benchmark and adjusting the resources to your needs, especially if you are going to run this compose in a production environment. |
| 77 | + |
| 78 | +##Cleanup |
| 79 | + |
| 80 | +To stop and remove the containers and volumes, run the following command: |
| 81 | + |
| 82 | +```shell |
| 83 | +docker compose down |
| 84 | +docker volume ls| grep"postgresml-docker"| awk'{print $2}'| grep -v"VOLUME"| xargs docker volume rm -f |
| 85 | +``` |