occlum/demos/python/python_glibc
2024-03-06 15:59:26 +08:00
..
dataset Add glibc-supported python demo 2021-06-08 07:54:10 +08:00
python3.10-multiprocessing [config] Add "feature" field to Occlum.json 2024-03-06 15:59:26 +08:00
.gitignore [vm] Support shared memory (POSIX) 2023-06-22 15:20:29 +08:00
demo.py Add glibc-supported python demo 2021-06-08 07:54:10 +08:00
install_python_with_conda.sh Reduce the size of python-related demo for CI 2023-08-14 09:59:19 +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 Update demos to enable EDMM features 2023-11-07 09:26:20 +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.