Update pytorch demo with copy_bom

This commit is contained in:
jianfengjiang 2021-09-26 11:18:51 +08:00 committed by Zongmin.Gu
parent 7290cfa561
commit 3f78b09df7
4 changed files with 28 additions and 17 deletions

@ -346,7 +346,7 @@ jobs:
# FIXME: PyTorch can't exit normally in SIM mode # FIXME: PyTorch can't exit normally in SIM mode
- name: Kill the container - name: Kill the container
run: | run: |
sleep 180; sleep 240;
cat "$GITHUB_WORKSPACE/log"; cat "$GITHUB_WORKSPACE/log";
if grep -q Done "$GITHUB_WORKSPACE/log"; then if grep -q Done "$GITHUB_WORKSPACE/log"; then
docker stop pytorch_test docker stop pytorch_test

@ -8,4 +8,4 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# 2. Install python and dependencies to specified position # 2. Install python and dependencies to specified position
[ -d Miniconda3-latest-Linux-x86_64.sh ] || wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh [ -d Miniconda3-latest-Linux-x86_64.sh ] || wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
[ -d miniconda ] || bash ./Miniconda3-latest-Linux-x86_64.sh -b -p $script_dir/miniconda [ -d miniconda ] || bash ./Miniconda3-latest-Linux-x86_64.sh -b -p $script_dir/miniconda
$script_dir/miniconda/bin/conda create --prefix $script_dir/occlum_instance/image/opt/python-occlum -y python=3.7 pytorch numpy torchvision -c pytorch $script_dir/miniconda/bin/conda create --prefix $script_dir/python-occlum -y python=3.7 pytorch numpy torchvision -c pytorch

@ -0,0 +1,17 @@
includes:
- base.yaml
targets:
- target: /bin
createlinks:
- src: /opt/python-occlum/bin/python3
linkname: python3
# python packages
- target: /opt
copy:
- dirs:
- ../python-occlum
# python code
- target: /
copy:
- files:
- ../demo.py

@ -7,26 +7,20 @@ NC='\033[0m'
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
python_dir="$script_dir/occlum_instance/image/opt/python-occlum" python_dir="$script_dir/occlum_instance/image/opt/python-occlum"
cd occlum_instance && rm -rf image
copy_bom -f ../pytorch.yaml --root image --include-dir /opt/occlum/etc/template
if [ ! -d $python_dir ];then if [ ! -d $python_dir ];then
echo "Error: cannot stat '$python_dir' directory" echo "Error: cannot stat '$python_dir' directory"
exit 1 exit 1
fi fi
cd occlum_instance new_json="$(jq '.resource_limits.user_space_size = "6000MB" |
# Copy files into Occlum Workspace and build .resource_limits.kernel_space_heap_size = "256MB" |
if [ ! -L "image/bin/python3" ];then .process.default_mmap_size = "4000MB" |
ln -s /opt/python-occlum/bin/python3 image/bin/python3 .env.default += ["PYTHONHOME=/opt/python-occlum"]' Occlum.json)" && \
cp -f /opt/occlum/glibc/lib/libdl.so.2 image/opt/occlum/glibc/lib/ echo "${new_json}" > Occlum.json
cp -f /opt/occlum/glibc/lib/libutil.so.1 image/opt/occlum/glibc/lib/ occlum build
cp -f /opt/occlum/glibc/lib/librt.so.1 image/opt/occlum/glibc/lib/
cp -f ../demo.py image
new_json="$(jq '.resource_limits.user_space_size = "6000MB" |
.resource_limits.kernel_space_heap_size = "256MB" |
.process.default_mmap_size = "4000MB" |
.env.default += ["PYTHONHOME=/opt/python-occlum"]' Occlum.json)" && \
echo "${new_json}" > Occlum.json
occlum build
fi
# Run the python demo # Run the python demo
echo -e "${BLUE}occlum run /bin/python3 demo.py${NC}" echo -e "${BLUE}occlum run /bin/python3 demo.py${NC}"