Using Private Instance
    • PDF

    Using Private Instance

    • PDF

    Article Summary

    Available in VPC

    You can perform data calculations in a separate analysis environment by utilizing a private instance. The private instance provides Jupyter Notebook for data analysis with Python code, and includes NAVER Cloud Platform's HOMEROS SDK, so you can write code easily.

    Create instances

    The following describes how to create a new instance on the console.

    Note

    Private instances can be created up to 1 individual member and up to 3 corporate members. Instance creation may be restricted according to the policy for each member type. If instance creation is not possible, please contact customer support.

    1. In the VPC environment of NAVER Cloud Platform Console, click Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Instances in this order.

    2. Click the [Create Instance] button.

    3. Enter an instance name, and select the library version.

    4. Select VPC, Subnet, and Server type referring to the following table.

      Server typeGPUvCPUMemoryDiskService zone
      CPU Intensive-816 GBSSD 50 GBKR-2
      CPU Intensive-1632 GBSSD 50 GBKR-2
      CPU Intensive-3264 GBSSD 50 GBKR-2
      GPU1890 GBSSD 50 GBKR-2
      GPU216180 GBSSD 50 GBKR-2
      GPU432360 GBSSD 50 GBKR-2
    Note

    Private instances are provided only in the KR-2 zone. Please select the Public Subnet of the KR-2 zone.

    1. Please enter the password to use Jupyter Notebook.

    2. Create separate working storage for homomorphic cryptographic operations and data analysis. Enter the storage size for storing homomorphic encryption keys and ciphertext.

    Note
    • Storage can be entered from a minimum of 50 GB to a maximum of 2000 GB.
    • Storage is charged at Block Storage rates separately from instances.
    • You cannot add storage after instance creation.
    1. Click the Create button and click the [OK] button in the instance creation confirmation pop-up window.

    Check instance list

    The created instance is displayed in the instance list in the console, and you can perform management operations such as starting, stopping, terminating, and checking the password from the list.

    To view the instance list, click Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Instances in the VPC environment of NAVER Cloud Platform Console.

    Start instance

    The procedure for starting a Stopped instance is as follows:

    1. In the VPC environment of NAVER Cloud Platform Console, click Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Instances in this order.
    2. Select the instance to start from the instance list and click the [Start] button.
    3. In the confirmation popup window, click the [Yes] button.

    Stop instance

    The procedure to stop an instance is as follows:

    1. In the VPC environment of NAVER Cloud Platform Console, click Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Instances in this order.
    2. Select the instance to stop from the instance list and click the [Stop] button.
    3. In the confirmation popup window, click the [Yes] button.
    Note

    Instances are charged even while stopped. Terminate the instance you decide not to use it.

    Terminate instance

    The procedure to terminate an instance is as follows:

    Note

    The working storage of the instance to be terminated is also deleted. Please back up necessary data in advance.

    1. In the VPC environment of NAVER Cloud Platform Console, click Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Instances in this order.
    2. Select the instance to terminate from the instance list and click the [Stop] button.
    3. When the instance status is at Stop, select the instance again then click on Terminate.
    Note

    Terminating an instance takes a few minutes. Once termination is completed, the instance is removed from your list of instance.

    Utilize Jupyter Notebook

    Access Jupyter Notebook

    You can access Jupyter Notebook while the instance is Running. The procedure to access Jupyter Notebook is as follows.

    1. In the VPC environment of NAVER Cloud Platform Console, click Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Instances in this order.
    2. Select the instance to access Jupyter Notebook from the instance list.
    3. Please click the URL of the Jupyter Notebook in instance details.
    Note

    If you cannot connect to Jupyter Notebook, you can restart as follows.

    1. SSH Login
    >> ssh homeros@{SERVER_IP}
    >> {JUPYTER_NOTEBOOK_PASSWORD}
    
    1. Run Jupyter Notebook service
    >> nohup jupyter notebook --config /home/homeros/.jupyter/jupyter_notebook_config.py > /home/homeros/.jupyter/log.out &
    
    Caution

    You can access Jupyter Notebook with the password entered during instance creation. You cannot use it if you lose your password. Please pay attention to management.

    Examples of Jupyter Notebook

    The standalone instance provides examples utilizing Jupyter Notebook and the HOMEROS SDK. If you go to the tutorial folder on the Jupyter Notebook screen, you can find various examples and data required to run the examples.

    An example in Jupyter Notebook is:

    0. Getting Started

    Provide a basic explanation of Jupyter Notebook examples.

    1. Overview of the basic structure of HOMEROS SDK

    Provide basic usage and examples for using HOMEROS SDK. Here are the highlights:

    1. Context: Describes context, the basic concept for generating and managing homomorphic key pairs. HOMEROS version 1.0 provides HEaaNContext implemented as HEaaN library based on CKKS scheme.
    2. We provide an example of encrypting data plaintext.
    3. Data transfer: describes the functions and examples provided for sharing ciphertext.
    4. Operations: provides functions and examples that perform homomorphic cryptographic operations.
      • It describes addition and multiplication operations.
      • It provides an example describing Depth, the maximum number of operations on a ciphertext.
    5. Decrypt: provides an example of decrypting a ciphertext.

    2. The statistic operations scenario

    It provides examples of arithmetic and statistical computation provided by HOMEROS. Please see the table below for the description of each computation and the minimum depth required to perform the calculation.

    Computation nameDepthComputation description
    Summation3Performs the addition of two ciphertexts.
    Sub3Performs the subtraction of two ciphertexts.
    Mult3Performs the multiplication of two ciphertexts.
    Add Const3Performs constant addition on one ciphertext.
    Sub Const3Performs constant subtraction on one ciphertext.
    Mult Const3Performs constant multiplication on one ciphertext.
    Computation nameDepthComputation description
    SummationFullReturns the sum of specified columns within a ciphertext.
    MeanFullReturns the mean of specified columns within a ciphertext.
    VarianceFullReturns the variance of specified columns within a ciphertext.
    Standard DerivationFullReturns the standard deviation of specified columns within a ciphertext.
    Standard ErrorFullReturns the standard error of specified columns within a ciphertext.
    Coefficient of VariationFullReturns the unique coefficient of specified columns within a ciphertext.
    Absolute ValueFullReturns the absolute value of each element of the ciphertext.
    SkewnessFullReturns the skewness of all elements of the ciphertext.
    KurtosisFullReturns the kurtosis of all elements in the ciphertext.
    CorrelationFullReturns the correlation coefficient of two ciphertexts.
    CovarianceFullReturns the covariance of two ciphertexts.
    Maximun ValueFullReturns the maximum of all elements of the ciphertext.
    Computation nameDepthComputation description
    Confidence interval of meanFullReturns the confidence interval of the mean of the ciphertext.
    Confidence interval of variance with chi-square distributionFullReturns the confidence interval for the variance using the chi-square distribution of the ciphertext.
    Computation nameDepthComputation description
    T-test for the mean of one sampleFullReturns a t-test for the mean of one sample.
    Z-test for proportion of one binomial sampleFullReturns the Z-test for the proportions in one binomial sample.
    Chi-square test for variance of one sampleFullReturns the chi-square test for the variance of one sample.
    T-test for the means of two samplesFullReturns a t-test for the mean of two samples.
    F-test for variances of two samplesFullReturns an f-test for the variance of two samples.

    3. The categorical operations scenario

    Categorical computation means statistical operation of a column that meets the condition when a specific column has categorical values. It provides examples of categorical arithmetic computations and categorical statistical calculations provided by HOMEROS. Most of the operations provided in Chapter 02 are provided, and the next examples are additionally provided.

    • Z test for the ratio of two binomial samples
    • Confidence interval for the probability of a population through the Z distribution

    4. Data concatenation scenario

    Data combining provides scenarios for combined analysis by sharing data from different institutions or enterprises.

    5. K means clustering prediction scenario

    K means clustering is one of the representative clustering techniques, and is used in various situations, such as labeling unlabeled or partial data for supervised learning or classifying data according to their characteristics. It provides an example of the K means clustering inference function of encrypted data provided by HOMEROS.

    6. Linear SVM prediction scenario

    Linear Support Vector Machine (SVM) is a representative machine learning algorithm mainly used for classification or regression of linear data. It is widely used in various fields due to its powerful function that comes from a relatively simple structure. It provides an example of the Linear SVM inference function of encrypted data provided by HOMEROS.

    7. Convolutional Neural Network with MNIST dataset prediction scenario

    It provides an encrypted inference example of Convolutional Neural Network (CNN), the most used deep learning algorithm for image analysis. Based on MNIST, one of the most commonly used examples in image analysis, it provides encrypted inference of a 2D CNN algorithm, as well as inference of a CNN model trained with Pytorch.

    8. Convolutional Neural Network with Fashion MNIST dataset prediction scenario

    It provides an example of changing the inference dataset to Fashion MNIST in the CNN example in Chapter 07.

    9. Linear Regression With training and prediction scenario

    Linear Regression is a machine learning algorithm with powerful performance despite its simple structure. It provides examples of Linear Regression learning in an encrypted state from HOMEROS and inference by decrypting the trained encrypted model.

    10. Logistic Regression With training and prediction scenario

    Logistic Regression is a machine learning algorithm with powerful performance despite its simple structure. It provides examples of Logistic Regression learning in an encrypted state from HOMEROS and inference by decrypting the trained encrypted model.

    11. Random forest prediction scenario

    Random Forest is a representative ensemble machine learning model, and it is used in many fields to compensate for the disadvantage that Decision Tree is highly likely to be overfitting. It provides an example of encrypted random forest inference provided by HOMEROS.

    12. XGBoost prediction scenario

    If Random Forest is a representative ensemble model, XGBoost is a representative boosting machine learning model that provides both classification and regression, and is an algorithm that is used based on its popularity due to its good performance and resource efficiency. It provides an example of encrypted XGBoost inference provided by HOMEROS.

    13. MLP(Multi Layers Perceptron) prediction scenario

    Multi Layer Perceptron is the most basic deep learning model. It provides an example of encrypted MLP inference provided by HOMEROS.

    SSH access

    You can connect to the server via SSH while the instance is running. The procedure to access SSH is as follows.

    1. In the VPC environment of NAVER Cloud Platform Console, click Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Instances in this order.
    2. Select the instance to access SSH from the instance list.
    3. Copy the IP address from URL of Jupyter Notebook in Instance details.
    4. You can access it through Terminal or PowerShell as follows. When connecting via SSH, enter the password set in the instance creation step.
    >> ssh homeros@{SERVER_IP}
    >> {JUPYTER_NOTEBOOK_PASSWORD}
    

    Deploy applications

    It describes how to deploy services using HOMEROS using Python-based development frameworks Flask and Django.

    In the development environment, Web Application Server (WAS) can be configured with only the Flask or Django framework itself, but in the deployment environment, these limitations can be overcome through the Web Server Gateway Interface (WSGI) for performance and security. WSGI is an interface created for Python scripts to communicate efficiently with a web server.

    This guide explains how to deploy applications using Gunicorn, one of the representative WSGI technologies, and Nginx, a representative web server that provides high speed, reverse proxy, and SSL.

    1. Install Flask

    (1) Install required package: Since the installation proceeds with the homeros account, not root, insert the --user option.

    pip3 install flask --user
    pip3 install MarkupSafe --user
    pip3 install Jinja2 --user
    pip3 install click --user
    

    (2) Create a basic Flask application: Create an app.py file in the folder where the Flask project is created, and write the following code.

    from flask import Flask
    app = Flask(__name__)
    @app.route('/')
    def home():
        return 'Hello, World!'
    if __name__ == '__main__':
        app.run(host='0.0.0.0', port=1080)
    
    Note
    • The host='0.0.0.0' setting is required to allow access from outside the instance.
    • Use the port variable for the desired port.

    (3) Application integration with Gunicorn: In case of opening port 8000, execute the following command in the place where the app.py file is located.

    gunicorn --bind 0.0.0.0:8000 app:app &
    

    2. Install Django

    (1) Install required package

    python3 -m pip install Django --user
    

    (2) Create django basic application: Execute the following command in the folder where the application will be created.

    django-admin startproject mysite
    

    (3) Application integration with Gunicorn: When opening port 8000 in the folder where the application name mysite is located, execute the following command.

    gunicorn --bind 127.0.0.1:8000 mysite.wsgi:application &
    

    3. Connect Nginx

    (1) Install Nginx (based on the latest version 1.20.2)

    Download the source code and proceed with the build. (The base folder is assumed to be /home/homeros/myproject/nginx)

    wget https://nginx.org/download/nginx-1.20.2.tar.gz
    

    Decompress the tar.gz file of the downloaded nginx.

    tar zxvf nginx-1.20.2.tar.gz 
    

    Change to the unzipped folder.

    cd nginx-1.20.2
    

    (2) Build

    Configure settings: Set to create log files, config files, and sbin files containing executable files under the /home/homeros/myproject/nginx path.

    ./configure \
      --prefix=/home/homeros/myproject/nginx/ \
      --user=homeros \
      --group=homeros \
      --error-log-path=/home/homeros/myproject/nginx/error.log \
      --http-log-path=/home/homeros/myproject/nginx/access.log \
      --without-http_scgi_module \
      --without-http_uwsgi_module \
      --without-http_fastcgi_module \
      --with-stream
    

    Run make

    make
    

    Run make install

    make install
    

    (3) Setting: Open the nginx.conf file at /home/homeros/myproject/nginx/conf and enter the following:

    vim nginx.conf
    server {
        listen $nginx port;
        …
    
        location / {
            proxy_pass http://127.0.0.1:$gunicorn port;
        }
    }
    

    For example, if the port connected with gunicorn is 8000 and you want to proxy it to port 8001 in nginx, edit it as follows.

    server {
        listen  nginx 8001;
        …
    
        location / {
            proxy_pass http://127.0.0.1:8000;
        }
    }
    

    (4) Run nginx

    /home/homeros/myproject/nginx/sbin/nginx
    

    (5) Close nginx

    /home/homeros/myproject/nginx/sbin/nginx -s stop
    

    Delete cache data

    If temporary files used by HOMEROS are not automatically deleted, you may run out of storage capacity. If work is impossible due to lack of storage space, you can secure additional storage space by deleting temporary files.

    1. Running Jupyter notebook shutdown

    Temporary files are deleted when the running Jupyter Notebook is shut down.

    If Jupyter Notebook is shut down but storage space is not secured, you can manually delete temporary files.

    2. Delete cache data

    (1) Terminal access: Terminal access is possible through [New] >> [Terminal] at the top right of Jupyter Notebook.

    Note

    To connect to the server through the terminal, connect as follows.

    >> ssh homeros@{SERVER_IP}
    >> {JUPYTER_NOTEBOOK_PASSWORD}
    

    (2) Check storage space

    >> df -h
    

    If the space under /home is insufficient, use the following command to check the capacity of the /home/homeros/.homeros/ folder.

    du -sh /home/homeros/.homeros/
    

    (3) Delete temporary files under .homeros: If the capacity of the .homeros folder is insufficient, delete temporary files in the .homeros directory to secure storage space.

    >> rm -rf /home/homeros/.homeros/*
    
    Caution
    • If you delete the .homeros directory itself, context creation becomes impossible, so you must delete only subdirectories or files.
    • Please note that files or folders deleted with the Linux delete command cannot be restored.

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.