The following describes how to install TurnkeyML.
This project is tested using ubuntu-latest
and windows-latest
. ubuntu-latest
currently defaults to Ubuntu 20.04. However, it is also expected to work on other recent versions of Ubuntu (e.g. 18.04, 22.04), and other flavors of Linux (e.g. CentOS).
We highly recommend the use of miniconda environments when:
If you are installing TurnkeyML on Linux, simply run the command below:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
If you are installing TurnkeyML on Windows, manually download and install Miniconda3 for Windows 64-bit. Please note that PowerShell is recommended when using miniconda on Windows.
Then create and activate a virtual environment like this:
conda create -n tkml python=3.8
conda activate tkml
First, make sure you have a copy of the repository locally:
git clone https://github.com/onnx/turnkeyml.git
Then, simply pip install the TurnkeyML package:
pip install -e turnkeyml
You are now done installing TurnkeyML!
If you are planning to use the turnkey
tools with the TurnkeyML models or Slurm please see the corresponding sections below.
The TurnkeyML models are located at install_path/models
, which we refer to as models/
in most of the guides.
Note: The
turnkey models-location
command andturnkey.common.filesystem.MODELS_DIR
are useful ways to locate themodels
directory. If you perform PyPI installation, we recommend that you take an additional step like this:
(tkml) jfowers:~$ turnkey models-location
Info: The TurnkeyML models directory is: ~/turnkeyml/models
(tkml) jfowers:~$ export models=~/turnkeyml/models
The turnkeyml
package only requires the packages to run the tools. If you want to run the models as well, you will also have to install the models' requirements.
In your miniconda
environment:
pip install -r models/requirements.txt
Slurm is an open source workload manager for clusters. If you would like to use Slurm to build multiple models simultaneously, please follow the instructions below.
Ensure that your turnkeyml clone and your conda installation are both inside a shared volume that can be accessed by Slurm. Then, run the following command and wait for the Slurm job to finish:
sbatch --mem=128000 src/turnkeyml/cli/setup_venv.sh
Some models from Huggingface.co might require the use of an API token. You can find your api token under Settings from your Hugging Face account.
To allow slurm to use your api token, simply export your token as an environment variable as shown below:
export HUGGINGFACE_API_KEY=<YOUR_API_KEY>
Both Torch Hub and Hugging Face models save model content to a local cache. A good practice is to store that data with users that might use the same models using a shared folder. TurnkeyML allows you to setup a shared ML download cache folder when using Slurm by exporting an environment variable as shown below:
export SLURM_ML_CACHE=<PATH_TO_A_SHARED_FOLDER>
Go to the models/
folder and build multiple models simultaneously using Slurm.
turnkey -i selftest/*.py --cache-dir PATH_TO_A_CACHE_DIR discover export-pytorch --use-slurm