Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PyTorch example for Ubuntu 24.04 #109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pytorch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

# PyTorch and the pre-trained model must be installed on the system. See README for details.

SHELL := /bin/bash

THIS_DIR := $(shell pwd)

VENV_DIR ?= $(THIS_DIR)/my_venv

ENTRYPOINT := $(VENV_DIR)/bin/python3

ARCH_LIBDIR ?= /lib/$(shell $(CC) -dumpmachine)

ifeq ($(DEBUG),1)
Expand All @@ -21,7 +29,8 @@ pytorch.manifest: pytorch.manifest.template
gramine-manifest \
-Dlog_level=$(GRAMINE_LOG_LEVEL) \
-Darch_libdir=$(ARCH_LIBDIR) \
-Dentrypoint=$(realpath $(shell sh -c "command -v python3")) \
-Dentrypoint=$(ENTRYPOINT) \
-Dvenv_dir=$(VENV_DIR) \
$< > $@

# Make on Ubuntu <= 20.04 doesn't support "Rules with Grouped Targets" (`&:`),
Expand Down
1 change: 1 addition & 0 deletions pytorch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ installation.
- `sudo apt install python3-pip lsb-release` to install `pip` and `lsb_release`.
The former is required to install additional Python packages while the latter
is used by the Makefile.
- `python3 -m venv my_venv && source my_venv/bin/activate` to create and activate a virtual environment.
- `pip3 install --user torchvision pillow` to install the torchvision and pillow
Python packages and their dependencies (usually in $HOME/.local). WARNING:
This downloads several hundred megabytes of data!
Expand Down
2 changes: 2 additions & 0 deletions pytorch/pytorch.manifest.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fs.mounts = [
{ path = "/usr/lib", uri = "file:/usr/lib" },
{ path = "{{ arch_libdir }}", uri = "file:{{ arch_libdir }}" },
{ path = "/usr/{{ arch_libdir }}", uri = "file:/usr/{{ arch_libdir }}" },
{ path = "{{ venv_dir }}", uri = "file:{{ venv_dir }}" },
{% for path in python.get_sys_path(entrypoint) %}
{ path = "{{ path }}", uri = "file:{{ path }}" },
{% endfor %}
Expand All @@ -43,6 +44,7 @@ sgx.trusted_files = [
"file:/usr/lib/",
"file:{{ arch_libdir }}/",
"file:/usr/{{ arch_libdir }}/",
"file:{{ venv_dir }}/",
{% for path in python.get_sys_path(entrypoint) %}
"file:{{ path }}{{ '/' if path.is_dir() else '' }}",
{% endfor %}
Expand Down