Certain operational systems used for machine learning or other tasks might not be connected to internet due to security concerns and privacy reasons. Such systems may also operate offline to prevent potential cyber threats or unauthorized access. Natural question that arises is that how does one create and / or deploy machine learning models on such offline systems? This technical article answers that question and documents steps needed to clone a Python based functional virtual machine learning environment from an online computer to an offline system.
This article specifically outlines steps that are necessary to install hana_ml package based virtual environment on a computer that is not connected to the Internet. The steps are demonstrative, and some computer environments may require different additional Python packages to enable specific task at hand. To allow for coexistence of multiple virtual Python environments on the same computer, free tool Miniconda was used in the following steps. There may exist other tools that provide similar functionality.
Steps as listed in the following have been tested for the following:
Please note that in the following, “|>” represents the Windows terminal prompt. Also, an alternate purely Python based methodology will be shared to accomplish the same in a companion blog.
|> conda create -y -n hanaml_online python=3.9
|> conda-env list
Newly created virtual environment should be listed in the output which should be as follows assuming that Miniconda was installed in its default location. Following output will change according to the installation directory of Miniconda.
# conda environments:
#
base C:\Users\%USERNAME%\AppData\Local\miniconda3
hanaml_online C:\Users\%USERNAME%\AppData\Local\miniconda3\envs\hanaml_online
|> activate hanaml_online
(hanaml_online) |> pip install hana_ml
(hanaml_online) |> python
Python 3.9.18 (main, Sep 11 2023, 14:09:26) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import hana_ml
ModuleNotFoundError: No module named 'shapely'
>>> print(hana_ml.__version__)
2.18.23111400
>>> import hana_ml.dataframe as dataframe
>>> quit()
(hanaml_online) |>
*Note: Python package shapely is missing. This omission is intentional. In a subsequent blog rationale for this omission and how to remedy it will be documented.
(hanaml_online) |> conda deactivate
|> conda install conda-pack
|> conda pack -n hanaml_online -o hanaml_offline.tar.gz
Collecting packages...
Packing environment at 'C:\\Users\\%USERNAME%\\AppData\\Local\\miniconda3\\envs\\hanaml_online' to 'hanaml_offline.tar.gz'
[########################################] | 100% Completed | 9.0s
C:\Users\%USERNAME%\AppData\Local\miniconda3\envs
|> cd C:\Users\%USERNAME%\AppData\Local\miniconda3\envs
|> mkdir hanaml_offline
|> tar xvf hanaml_offline.tar.gz -C hanaml_offline
|> conda-env list
# conda environments:
#
Base C:\Users\%USERNAME%\AppData\Local\miniconda3
hanaml_offline C:\Users\%USERNAME%\AppData\Local\miniconda3\envs\hanaml_offline
|> activate hanaml_offline
(hanaml_offline) |> python
Python 3.9.18 (main, Sep 11 2023, 14:09:26) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import hana_ml
ModuleNotFoundError: No module named 'shapely'
>>> print(hana_ml.__version__)
2.18.23092701
>>> import hana_ml.dataframe as dataframe
>>> quit()
(hanaml_offline) |> conda deactivate