LogoLogo
WebsiteSlack
0.30
0.30
  • Get started
  • Clients
    • Install
    • CLI commands
    • Python API
    • Environments
    • Telemetry
    • Uninstall
  • Workloads
    • Realtime APIs
      • Example
      • Predictor
      • Configuration
      • Models
      • Parallelism
      • Server-side batching
      • Autoscaling
      • Statuses
      • Metrics
      • Multi-model
        • Example
        • Configuration
        • Caching
      • Traffic Splitter
        • Example
        • Configuration
      • Troubleshooting
    • Batch APIs
      • Example
      • Predictor
      • Configuration
      • Jobs
      • Statuses
    • Task APIs
      • Example
      • Definition
      • Configuration
      • Jobs
      • Statuses
    • Dependencies
      • Example
      • Python packages
      • System packages
      • Custom images
    • Observability
      • Logging
      • Metrics
  • Clusters
    • AWS
      • Install
      • Update
      • Auth
      • Security
      • Spot instances
      • Networking
        • Custom domain
        • HTTPS (via API Gateway)
        • VPC peering
      • Setting up kubectl
      • Uninstall
    • GCP
      • Install
      • Credentials
      • Setting up kubectl
      • Uninstall
    • Private Docker registry
Powered by GitBook
On this page
  1. Workloads
  2. Dependencies

System packages

PreviousPython packagesNextCustom images

Last updated 4 years ago

Cortex looks for a file named dependencies.sh in the top level Cortex project directory (i.e. the directory which contains cortex.yaml). For example:

./my-classifier/
├── cortex.yaml
├── predictor.py
├── ...
└── dependencies.sh

dependencies.sh is executed with bash shell during the initialization of each replica (before installing Python packages in requirements.txt or conda-packages.txt). Typical use cases include installing required system packages to be used in your Predictor, building Python packages from source, etc. If initialization time is a concern, see for how to build and use custom Docker images.

Here is an example dependencies.sh, which installs the tree utility:

apt-get update && apt-get install -y tree

The tree utility can now be called inside your predictor.py:

# predictor.py
import subprocess

class PythonPredictor:
    def __init__(self, config):
        subprocess.run(["tree"])
    ...

If you need to upgrade the Python Runtime version on your image, you can do so in your dependencies.sh file:

# upgrade python runtime version
conda update -n base -c defaults conda
conda install -n env python=3.8.5

# re-install cortex core dependencies
/usr/local/cortex/install-core-dependencies.sh

Customizing Dependency Paths

Cortex allows you to specify a path for this script other than dependencies.sh. This can be useful when deploying different versions of the same API (e.g. CPU vs GPU dependencies). The path should be a relative path with respect to the API configuration file, and is specified via predictor.dependencies.shell.

For example:

# cortex.yaml

- name: my-classifier
  kind: RealtimeAPI
  predictor:
    (...)
    dependencies:
      shell: dependencies-gpu.sh
Docker images