Skip to content

Latest commit

 

History

History
236 lines (139 loc) · 6.98 KB

installation.md

File metadata and controls

236 lines (139 loc) · 6.98 KB

NOTE: Refer to the online documentation to properly view this file

Installation

The MLTK supports three modes of installation:

[Python3 9,10,11, or 12](https://www.python.org/downloads/) is required

Standard Python Package

This describes how to install the MLTK Python package into your Python3 environment.

- Before installing, you must have [Python 3.9, 3.10, 3.11, 3.12](https://www.python.org/downloads/) installed on your computer
- Installing the MLTK will also install Google [Tensorflow](https://www.tensorflow.org/install) into your Python environment,
  if your computer has an NVidia GPU, then ensure the proper drivers are [installed](https://www.tensorflow.org/install/gpu)
- If you're using Windows, be sure to install the [Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) which is required by [Tensorflow](https://www.tensorflow.org/install/pip)

1 ) Optionally create and activate a Python virtual environment:

This step is highly recommended as the MLTK installs other dependencies like Tensorflow into the Python environment.

.. tab-set::

   .. tab-item:: Windows

      .. code-block:: shell

         python  -m venv mltk_pyvenv
         .\mltk_pyvenv\Scripts\activate.bat

   .. tab-item:: Linux

      .. code-block:: shell

         python3 -m venv mltk_pyvenv
         source ./mltk_pyvenv/bin/activate

2 ) Install the MLTK Python package via pip:

This installs the pre-built Python package. This is the easiest and fastest approach to installing the MLTK.
However, the package may not be up-to-date with the Github repository.

.. tab-set::

 .. tab-item:: Windows

    .. code-block:: shell

       pip  install silabs-mltk[full] --upgrade

 .. tab-item:: Linux

    .. code-block:: shell
    
       pip3 install silabs-mltk[full] --upgrade

Alternatively,

This builds and installs the Python package from the Github repository.
This will take longer to install but will use the most up-to-date source code.

.. tab-set::

 .. tab-item:: Windows

    .. code-block:: shell

       pip  install "silabs-mltk[full] @ git+https://github.com/siliconlabs/mltk.git"

 .. tab-item:: Linux

    .. code-block:: shell
    
       pip3 install "silabs-mltk[full] @ git+https://github.com/siliconlabs/mltk.git"

NOTE: The silabs-mltk[full] @ part of the command is optional. This will install additional dependencies used by some the the MLTK commands. Omitting this from the command will speedup installation but may cause some of the commands like classify_audio, view, tensorboard to require additional install step.

After the command completes, the MLTK should be available to the current Python environment.
You can verify by issuing the command:

mltk --help

See the Command-Line Guide for more details on how to use the command-line.

You can also import the MLTK via Python script, e.g.:

from mltk.core import profile_model

profile_model('~/my_model.tflite')

See the API Examples for more details on how to use the MLTK Python API.

Update Python Package

If the MLTK Python package has already been installed, you may update to the latest MLTK by running the command:

.. tab-set::

   .. tab-item:: Windows

      .. code-block:: shell

         pip  install silabs-mltk[full] --upgrade

   .. tab-item:: Linux

      .. code-block:: shell

         pip3 install silabs-mltk[full] --upgrade

Alternatively, you can update to a specific version with:

.. tab-set::

   .. tab-item:: Windows

      .. code-block:: shell

         pip  install silabs-mltk[full]==0.20.0

   .. tab-item:: Linux

      .. code-block:: shell

         pip3 install silabs-mltk[full]==0.20.0

and replace 0.20.0 with the desired version.

Google Colab

Google offers it own free Cloud servers for model training, Google Colaboratory (a.k.a. Colab).
This is very useful as you can leverage Google's cloud servers and GPUs for training your model. The following describes how to install the MLTK into a Colab notebook.

1 ) Create a Google Account (if necessary)
Go to the Google Signup page.
NOTE: Click the Use my current email address instead button to use your existing email instead of creating a gmail email address.

2 ) Refer to the Colab Basic Features Overview to get a basic idea of how notebooks work
3 ) Create a new Colab notebook
4 ) Create a Python code cell and copy & paste the following into the cell

!pip install --upgrade silabs-mltk

5 ) Execute the cell
Once the cell executes, the MLTK will be installed. You may import and use the MLTK package as normal from this point on inside the notebook

Local Development

The MLTK can also be installed for local development. In this mode, the Python C++ wrappers are built from source.
Additionally, a new Python virtual environment is created specifically for the MLTK.

Before installing, you must have [Python3.9,10,11, or 12](https://www.python.org/downloads/) installed on your computer

1 ) Clone the MLTK GIT repository

git clone https://github.com/siliconlabs/mltk

2 ) Run the install script at the root of the repository

.. tab-set::

   .. tab-item:: Windows

      .. code-block:: shell

         cd mltk
         python  .\install_mltk.py

   .. tab-item:: Linux

      .. code-block:: shell

         cd mltk
         python3 ./install_mltk.py

The install script will:

  1. Create a python virtual environment at <mltk root>/.venv
  2. Install the MLTK Python package for local development into Python virtual environment:
    pip install -e .
- [C++ Development](./cpp_development/index.md) - Describes how to build and run MLTK C++ applications