43 lines
1.6 KiB
Desktop File
43 lines
1.6 KiB
Desktop File
# systemd user unit of the ML service on a GPU host without Docker. Install it
|
|
# as ~/.config/systemd/user/lincodex-ml.service of the service user (with
|
|
# lingering enabled) and keep the settings and the token in the environment
|
|
# file, mode 600; see docs/en/DEPLOYMENT.md#ml-service-on-a-gpu-host.
|
|
#
|
|
# %h is the home directory of the user: the layout below is
|
|
# %h/lincodex-ml/app/ml the ml/ directory of the release
|
|
# %h/lincodex-ml/venv the virtualenv (make -C ml cuda-requirements)
|
|
[Unit]
|
|
Description=Lincodex ML embedding service
|
|
StartLimitIntervalSec=600
|
|
StartLimitBurst=10
|
|
|
|
[Service]
|
|
Type=exec
|
|
WorkingDirectory=%h/lincodex-ml/app/ml
|
|
EnvironmentFile=%h/.config/lincodex-ml/ml.env
|
|
Environment=PYTHONPATH=%h/lincodex-ml/app/ml/src
|
|
Environment=PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
|
# The models are read from local files only; nothing is downloaded.
|
|
Environment=HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 HF_HUB_DISABLE_TELEMETRY=1 HF_HUB_DISABLE_PROGRESS_BARS=1
|
|
# Thread pools of the CPU work around the GPU (tokenizer, pooling).
|
|
Environment=OMP_NUM_THREADS=4 MKL_NUM_THREADS=4 TOKENIZERS_PARALLELISM=false
|
|
# A permanent load failure ends the process, so systemd restarts it later.
|
|
Environment=ML_EXIT_ON_LOAD_FAILURE=true
|
|
ExecStart=%h/lincodex-ml/venv/bin/python -m lincodex_ml.serve
|
|
Restart=on-failure
|
|
RestartSec=15
|
|
TimeoutStopSec=30
|
|
# The process with both models on CUDA keeps about 2.6 GiB resident (peak
|
|
# 2.9 GiB); the limits keep a fault from starving the other host services.
|
|
MemoryHigh=5G
|
|
MemoryMax=6G
|
|
CPUQuota=400%
|
|
TasksMax=512
|
|
LimitNOFILE=4096
|
|
Nice=5
|
|
NoNewPrivileges=yes
|
|
UMask=0077
|
|
|
|
[Install]
|
|
WantedBy=default.target
|