occlum/demos/python/python_glibc
2022-10-27 10:32:01 +08:00
..
dataset Add glibc-supported python demo 2021-06-08 07:54:10 +08:00
.gitignore Fix the script of running Python demo 2021-07-13 19:31:28 +08:00
demo.py Add glibc-supported python demo 2021-06-08 07:54:10 +08:00
install_python_with_conda.sh Set conda python version as 3.8.10 to workaround non-PIE issues 2022-10-27 10:32:01 +08:00
python-glibc.yaml modify demos after implementing autodep for copydirs 2021-09-24 19:02:26 +08:00
README.md Upgrade the version of Occlum docker image in README.md 2021-06-22 08:04:03 +08:00
run_python_on_occlum.sh Fix python3.7 PIE issue 2022-10-21 11:02:18 +08:00

Use Python with Occlum

This project demonstrates how Occlum enables unmodified Python programs running in SGX enclaves, which is based on glibc.

Sample Code: CSV Processing in Python

To make the sample code more realistic, we choose to write a Python program that processes CSV data files using NumPy, pandas, and scikit-learn. The sample code can be found here.

How to Run

This tutorial is written under the assumption that you have Docker installed and use Occlum in a Docker container.

Occlum is compatible with glibc-supported Python, we employ miniconda as python installation tool. You can import any python dependencies using conda. Here, miniconda is automatically installed by install_python_with_conda.sh script, the required python and related dependencies for this project are also loaded by this script. Here, we take occlum/occlum:0.23.0-ubuntu18.04 as example.

Step 1 (on the host): Start an Occlum container

docker pull occlum/occlum:0.23.0-ubuntu18.04
docker run -it --name=pythonDemo --device /dev/sgx/enclave occlum/occlum:0.23.0-ubuntu18.04 bash

Step 2 (on the host): Download miniconda and install python to prefix position.

cd /root/occlum/demos/python/python_glibc
bash ./install_python_with_conda.sh

Step 3 (on the host): Run the sample code on Occlum

cd /root/occlum/demos/python/python_glibc
bash ./run_python_on_occlum.sh

It will process CSV data files and generate a file (smvlight.dat) in ./occlum_instance.