Using Fortanix Confidential Computing Manager to run an Enclave OS pre-trained Object Detection Tensorflow Model


In this example, we will demonstrate a TensorFlow (TF) Model running inside an enclave using the Fortanix Confidential Computing Manager (CCM). For this example, we are taking the object detection model from this URL. This is a pre-trained TF model, capable of classifying basic objects from an image such as a cat, a dog, a table, and so on.

Authenticate to Fortanix CCM

Before you can issue any requests, you first need to authenticate to Fortanix CCM using the following commands:

cpath=$(mktemp -p "/tmp" -t "fortanix_ccm_cookie.XXXXX")
curl -u <username>:<password> -c $cpath -X POST

where <username> and <password> need to be replaced with the email address and password of your Fortanix CCM account.

Authentication session tokens are short-lived. If you ever get the response {"message":"Forbidden","code":"FORBIDDEN"} you can run the following command to refresh the session token.
curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -X POST

Select an Account Using an API Call

Once you have successfully authenticated to Fortanix CCM, you need to select an account. First, you can list all accounts available using the following command:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true"

This command will return a JSON string of the following form:

{"name":"My account","acct_id":"26eaa328-5eb4-41c7-b09b-8a3e0a0f65c7", ...}, ...

To select an account you need to copy the account id of the account you are interested in (the string 26eaa328-5eb4-41c7-b09b-8a3e0a0f65c7 in the example above), let us call it <account_id>, and run:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -X POST<account_id>

Create an Application

Create a TF Object Detection Model application using the configuration provided in the app.json file below.

fortanix/tensorflow-serving:1.9.0-faster_rcnn_resnet_serving-sgx is the converted, enclave-os image which can be directly run on the enrolled node.
"name": "Object Detection TF Model",
"description": "Faster Rcnn Resnet Object Detection Model",
"input_image_name": "fortanix/tensorflow-serving",
"output_image_name": "<repository_path_where_output_image_will_be_stored>",
"isvprodid": 1,
"isvsvn": 1,
"mem_size": 4096,
"threads": 128
curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -H "Content-Type: application/json" -d @app.json -X POST

Create an Image Using an API Call

Once the application has been created, you can similarly create an image by following these steps.

  • First, create a file called build.json as shown below.
  • Replace <app_id> with the ID of your newly created application.
  • The <username> and <password> are the credentials of the registry that you want the converted image to be stored at. This was specified above as output_image_name.
"app_id": "<app_id>",
"input_docker_version": "latest",
"output_docker_version": "sgx",
"outputAuthConfig": {
"username": "<username>",
"password": "<password>"


See the Fortanix CCM Quickstart guide on how to set up registry credentials to avoid including credentials in this file.

Now you can create the image using the following command:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -H "Content-Type: application/json" -d @build.json -X POST

Approve Task

This returns the output that shows the <task_id> (f0d815b6-9520-4ce4-b4f4-6a82a718bb7e in this example), among other information:


Finally, you can approve the image using <task_id> of the image and the following command:

curl -b $cpath -c $cpath -H "X-CSRF-Header:true" -H "Content-Type: application/json" -d '{"status":"APPROVED"}' -X PATCH<task_id>

Run the Application

Whether you chose to create your application using the UI or the API option, you should now have converted and whitelisted an application image and can run the application on an SGX compute node. Depending on the node agent attestation type, run the application using one of the following commands:

For the node attestation type is Enhanced Privacy ID (EPID)/Data Center Attestation Primitives (DCAP), use the command:

docker run --privileged --volume /dev:/dev -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket -e NODE_AGENT_BASE_URL=http://<your_ip>:9092/v1/ -p 9000:9000 <registry>/tensorflow/serving:sgx


sudo docker run -it --device /dev/sgx/enclave:/dev/sgx/enclave -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket -e NODE_AGENT_BASE_URL= -p 9000:9000
Fortanix(R) EnclaveOS Runtime Encryption Platform 3.1.340-EM
Copyright 2017-2021 Fortanix, Inc. All rights reserved.
2021-04-28 02:48:30.784800: I tensorflow_serving/model_servers/] Building single TensorFlow model file config: model_name: model model_base_path: /models/model
2021-04-28 02:48:30.832495: I tensorflow_serving/model_servers/] Adding/updating models.
2021-04-28 02:48:30.832572: I tensorflow_serving/model_servers/] (Re-)adding model: model



Please sign in to leave a comment.

Was this article helpful?
0 out of 0 found this helpful