Install Packages

Add Python libraries to your deployment endpoints using a requirements file. Valohai installs these when building your deployment.

Create requirements file

Add a file named requirements-deployment.txt to your repository:

sqlalchemy==2.0.0
fastapi==0.104.1
pydantic==2.5.0

If requirements-deployment.txt doesn't exist, Valohai falls back to requirements.txt

Why separate files?

Training requirements (requirements.txt):

  • Heavy ML libraries (TensorFlow, PyTorch)

  • Data processing tools (pandas, scikit-learn)

  • Experiment tracking (MLflow, Weights & Biases)

Deployment requirements (requirements-deployment.txt):

  • Lightweight inference libraries

  • Web frameworks (FastAPI, Flask)

  • Production utilities (monitoring, logging)

Keeping them separate results in smaller, faster-loading deployment images.

When packages install

Valohai installs packages when you create a new deployment version. If you update requirements:

  1. Commit and push the changes

  2. Create a new deployment version

  3. Packages install during the build process

Troubleshooting

Package not found during runtime:

  • Verify it's in requirements-deployment.txt

  • Check build logs for installation errors

  • Ensure the package name and version are correct

Deployment build fails:

  • Look for dependency conflicts in build logs

  • Pin versions explicitly: fastapi==0.104.1 instead of fastapi

  • Test locally first: pip install -r requirements-deployment.txt


Next: Learn how to troubleshoot deployments when things go wrong.

Last updated

Was this helpful?