How to install STM32 model zoo

Revision as of 18:49, 30 September 2023 by Registered User

This article explains how to install the STM32 model zoo in ST Windows environment

1. Prerequisite

you need to have access to the direct proxy.

2. Install STM32Cube.AI

Or, for using STM32Cube.AI locally,

  • Install STM32Cube.AI through STM32CubeMX

Follow the instruction here: How_to_install_X-CUBE-AI_through_STM32CubeMX How to install X-CUBE-AI throughSTM32CubeMX. This is the official installation recommended process as it will work either with STM32CubeMX or by accessing to the Command Line Interface executable. The windows CLI executable stm32ai.exe is installed by default in the following path C:/Users/username/STM32Cube/Repository/Packs/STMicroelectronics/X-CUBE-AI/8.1.0/Utilities/windows/stm32ai.exe Replacing username by your windows user directory name.

  • Alternatively, install only the STM32Cube.AI Command Line Interface

Note that this installation procedure is not officially documented. Download the latest version of STM32Cube.AI for Windows. Extract and unzip the package stm32ai-windows-8.1.0.zip in a directory such as C:/stm32ai. The path to the executable will then be C:/stm32ai/windows/stm32ai.exe

3. Install STM32 model zoo

Install git for Windows.

For using git behind ST proxy add following to the .gitconfig file under your C:/Users/username/. If the file does not exist already create an empty file and add the following lines:

This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms that can be found here for the component: Linker Scripts.

<source lang="c"> [user]

name = FirstName SecondName
email = st.email@st.com

[http]

sslVerify = false
proxy = http://username:password.@proxy.url.com:8080

[https]

sslVerify = false
proxy = http://username:password.@proxy.url.com:8080

Replace the username with the ST Windows login username, and password with the password you use to login to Windows account. UTF-8 encode the password if it has any special characters. Replace the email address with your ST email address. Replace the proxy.url.com with lps5.gnb.st.com or any proxy that is provided to you by your local IT.

For training the models on the PC o When using GPU, make sure to install the GPU drivers. For NVIDIA GPUs, please refer to https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html to install CUDA and CUDNN.  On Windows OS, it is not recommended to use WSL as it can result in suboptimal acceleration for training on GPU. • To get the code repository of stm32ai-modelzoo in your PC: o Clone the repository using the following command: git clone https://github.com/STMicroelectronics/stm32ai-modelzoo.git • For using git behind ST proxy add following to the .gitconfig file under your C:/Users/username/. If the file does not exist already create an empty file and add the following lines: [user] name = FirstName SecondName email = st.email@st.com [http] sslVerify = false proxy = http://username:password.@proxy.url.com:8080 [https] sslVerify = false proxy = http://username:password.@proxy.url.com:8080 • Replace the username with the ST Windows login username, and password with the password you use to login to Windows account. o UTF-8 encode the password if it has any special characters. • Replace the email address with your ST email address. • Replace the proxy.url.com with lps5.gnb.st.com or any proxy that is provided to you by your local IT.

NOTE: The deployment of the models works even without having the local installation of STM32Cube.AI.

Installing Python requirements • If you don't have python installed already, you can download and install it from [here]. o Python Version <= 3.10 is required to be able to use required version of TensorFlow later, we recommend Python v3.9 or v3.10. o For Windows systems make sure to check the Add python.exe to PATH option during the installation process.  Having multiple versions installed can be a problem, so it is recommended to remove the paths for the other Python versions installed and keep only the one installed for STM32 Model Zoo. o For Linux add the path of the Python installation to your paths using export command or modifying ~/.bashrc file. • Navigate to the model zoo directory and create a python virtual environment for the project using venv: cd stm32ai-modelzoo python -m venv st_zoo • Activate your virtual environment. o For Windows run: st_zoo\Scripts\activate.bat o For Linux or MacOS, run: source st_zoo/bin/activate • Then install all the necessary python packages. A list of all the required python packages is provided in requirement.txt file. o pip install -r requirements.txt

  Setting up proxy and SSL variables If you are running behind ST proxy, you will face different issues when you try to install the python packages with the pip command or when you will try to access the STM32Cube.AI Developer cloud. To avoid these issues or to install python packages using pip, will require to set the environment variables named as `http_proxy`, `https_proxy`, and `NO_SSL_VERIFY`. This can be achieved by either using GUI or through CLI (command prompt).

Setting Environment variables Using GUI Open the environment variable dialog by pressing the Windows button () entering the term “environment variables” in the search bar. Open the application “Edit the System Environment Variables” or “Edit your account Environment Variables”.


  Then click on the new button to add a new environment variable:


• Replace username with your ST window login username. • Replace password with your ST window login password. o If the password contains some special character such as @, %, & or! you need to UTF-8 encode these characters. For example, if your password is Paris@75, this will become Paris%4075. You can use this link for the encoding. • Replace the <proxy.url.com> with your proxy string. For example, we can use lps5.gnb.st.com. • Replace the port with 8080. Repeat the same process for adding another variable called https_proxy. • Note use the same string for both proxies to avoid certificate issues. e.g., even for the variable https_proxy, the value will be http://username:password@proxy.url.com:port Add a variable to disable SSL Verification • Click >New o Variable name: NO_SSL_VERIFY o Variable value: 1   After entering these three variables the variables should look something like this:


Click OK to save the environment variables.

Bonus: In the context of the STM32 model zoo, users are required to create a secure connection with the developer cloud, before they can execute any operation, i.e., analyze, benchmark, quantize. This required them to enter the username and password for my-ST account in the prompt window. To avoid entering the credentials every time, users can add two environment variables to have store their username and password and name them `stmai_username` and `stmai_password` following the method described above.

In the model zoo context, the code will look for these environment variables and will always use these to enter them automatically at the time of connection creation and users will not have to enter the username and password again and again. However, the variables have to be exactly named as described here.   Setting Environment variables Using CLI

Alternatively, one can set the environment variables using the command prompt in Windows or Terminal in the Linux PC. For using the command prompt, execute following commands: • set NO_SSL_VERIFY="1" • set http_proxy="http://username:password@proxy.url.com:8080" • set https_proxy= :http://username:password@proxy.url.com:8080” • set stmai_username=<my-username> • set stmai_password=<stmai-password> o You must use the http string for both http as well as https proxy. o Replace the username with your ST windows login username. o Replace the password with your ST windows login password.  The password in the proxy string must be UTF-8 encoded if it contains any special characters. For example, if your password is Paris@75 it translates to: Paris%4075. You can use this link to do the encoding. o The stmai_username is the login for your myST account. o The stmai_password is the password for your myST account.  The password in the stmai_password string does not need to be encoded. You should be able to verify that the environment variables have been set by issuing an echo command in command prompt. o echo %variable_name% Setting Environment Variables in Linux For setting the environment variables on the machines using Linux OS, the users must add the following lines in .bashrc file. This can be done by first issuing command: $ nano ~/.bashrc This will open .bashrc file in the editable mode. Navigate to the end of .bashrc file and add following lines: export https_proxy='http://username:password.@proxy.url.com:8080' export http_proxy=' http://username:password.@proxy.url.com:8080' export SSL_VERIFY=false export stmai_username=’user.name@example.com’ export stmai_password=’password’

NOTE: • You must use the http string for both http as well as https proxy. • Replace the username with your ST windows login username. • Replace the password with your ST windows login password. o The password in the proxy string must be UTF-8 encoded if it contains any special characters. For example, if your password is Paris@75 it translates to: Paris%4075. You can use this link to do the encoding. • The stmai_username is the login for your myST account. • The stmai_password is the password for your myST account. o The password in the stmai_password string does not need to be encoded. Once these lines are added, press ‘CTRL + S’ button and then ‘CTRL + X’ to exit. Finally, to take these changes into account run following command: $ source ~/.bashrc


You should be able to verify that the environment variables have been set by issuing an echo command in command prompt. o $ echo $variable_name

WARNING: If there are some white spaces in the paths for Cube.AI or CubeIDE this will result in errors.

No categories assignedEdit