How do I Use Anacoda/Cona with Inference.ai?

Written By chloe kwok

Last updated 10 months ago

Yes! Inference.ai fully supports Anaconda and conda environments.

You can use conda to manage packages, create virtual environments, and install dependencies just like you would on a local machine.

Getting Started

Once your server is running:

  1. Open a terminal (via SSH or JupyterLab)

  2. Create a new environment

Example
conda create -n myenv python=3.10 conda activate myenv
  1. Install packages as needed:

Example
conda install numpy pandas scikit-learn

Pro tip: Environments and packages are reset when the server stops, unless you are using persistent storage

Keeping Your Python Environment in Permanent Storage

Note that:

  • Conda must be installed and be on your path

  • The OS which the environment was built must match the OS of the target

  • Once an environment is unpacked and conda-unpack has been executed, it cannot be relocated

  1. Create a Server

  1. Select Show Details

  1. Select the Jupyter-labs link from the HTTP Ports segment

  1. Select Terminal

  1. Run conda create -p /tmp/env python=3.12 numpy pandas -y

  2. Run conda install -n base -c conda-forge conda-pack -y

  1. Run conda-pack -p /tmp/env -o myenv.tar.gz

  1. Run mv myenv.tar.gz /home/jovyan/work

Do this portion on the target machine

  1. Unpack the environment into your directory with $ mkdir -p my_env $ tar -xzf out_name.tar.gz -C my_env

  2. Use Python without activating or fixing the prefixes ./my_env/bin/python

  3. Activate the environment $ source my_env/bin/activate

  4. Run Python from in the environment (my_env) $ python

  5. Cleanup prefixes from in the active environment (my_env) $ conda-unpack

  6. Run (my_env) $ ipython --version

  7. Deactivate the environment to remove it from your path (my_env) $ source my_env/bin/deactivate