|
1 | 1 | # How to use CC provision |
2 | 2 |
|
3 | | -In project.yml, under each site add "cc_config: [file]", for example: |
| 3 | +This guide explains how to use **CC (Confidential Computing) Provision** in NVFLARE, including setting up site configurations, enabling the CC builder, and using Docker images for CC workloads. |
| 4 | + |
| 5 | + |
| 6 | +## 0. Prepare application docker image workload |
| 7 | + |
| 8 | +In CC, we don't allow custom code, all the codes and required libs must be built-in in the docker image. |
| 9 | +In this example, we show you how to build NVFlare docker images in [docker/](docker/README.md) |
| 10 | + |
| 11 | + |
| 12 | +## 1. Define CC Configuration per Site (`cc_config`) |
| 13 | + |
| 14 | +Each site participating in a CC job must provide a **CC configuration file**. This file describes the trusted execution environment (e.g., AMD SEV-SNP on-prem CVM), drive allocations, and attestation policies. |
| 15 | + |
| 16 | +Here is an example (`cc_server.yml`): |
| 17 | + |
| 18 | + |
| 19 | +```yaml |
| 20 | +compute_env: onprem_cvm |
| 21 | +cc_cpu_mechanism: amd_sev_snp |
| 22 | +role: server |
| 23 | + |
| 24 | +# All drive sizes are in GB |
| 25 | +root_drive_size: 10 |
| 26 | +applog_drive_size: 1 |
| 27 | +user_data_drive_size: 1 |
| 28 | +secure_drive_size: 10 |
| 29 | + |
| 30 | +# Docker image archive saved using: |
| 31 | +# docker save <image_name> | gzip > app.tar.gz |
| 32 | +docker_archive: /tmp/base_images/app.tar.gz |
| 33 | + |
| 34 | +allowed_ports: |
| 35 | +- 8002 |
| 36 | + |
| 37 | +cc_issuers: |
| 38 | + - id: snp_authorizer |
| 39 | + path: nvflare.app_opt.confidential_computing.snp_authorizer.SNPAuthorizer |
| 40 | + token_expiration: 100 # seconds, needs to be less than check_frequency |
| 41 | +cc_attestation: |
| 42 | + check_frequency: 120 # seconds |
| 43 | + failure_action: stop_job |
| 44 | +``` |
| 45 | +
|
| 46 | +## 2. Reference `cc_config` in `project.yml` |
| 47 | + |
| 48 | +In your `project.yml`, reference the CC configuration file for each site using the `cc_config` key: |
4 | 49 |
|
5 | 50 | ```yaml |
6 | 51 | participants: |
7 | | - - name: site-1 |
8 | | - type: client |
| 52 | + - name: server1 |
| 53 | + type: server |
9 | 54 | org: nvidia |
10 | | - cc_config: cc_site-1.yml |
| 55 | + fed_learn_port: 8002 |
| 56 | + cc_config: cc_server1.yml |
11 | 57 | ``` |
12 | 58 |
|
13 | | -Then in the end of builders add: |
| 59 | +## 3. Add the CCBuilder |
14 | 60 |
|
15 | | -``` |
| 61 | +At the end of the `builders` section in your `project.yml`, add the `CCBuilder`: |
| 62 | + |
| 63 | +```yaml |
16 | 64 | builders: |
17 | 65 | - path: nvflare.lighter.cc_provision.impl.cc.CCBuilder |
18 | 66 | ``` |
19 | 67 |
|
20 | | -Then use the following command to generate startup kits: |
21 | | -
|
22 | | -```bash |
23 | | -nvflare provision -p project.yml |
24 | | -``` |
| 68 | +This builder sets up all CC-related configurations and assets. |
25 | 69 |
|
26 | | -# NVFlare application code package |
| 70 | +## 4. Add the OnPremPackager |
27 | 71 |
|
28 | | -For CC jobs, we don't allow custom codes, so we must pre-install those codes inside each CVM. |
29 | | -We utilize our nvflare pre-install command to do that. |
30 | | - |
31 | | -First, we need to prepare the application_code_zip folder structure: |
| 72 | +To generate startup kits for on-premises deployment, add the `OnPremPackager`: |
32 | 73 |
|
33 | | -```bash |
34 | | -application_code_folder |
35 | | -├── application/ # optional |
36 | | -│ └── <job_name>/ |
37 | | -│ ├── meta.json # job metadata |
38 | | -│ ├── app_<site>/ # Site custom code |
39 | | -│ └── custom/ # Site custom code |
40 | | -├── application-share/ # Shared resources |
41 | | -| └── simple_network.py # Shared model definition |
42 | | -└── requirements.txt # Python dependencies (optional) |
| 74 | +```yaml |
| 75 | +packager: |
| 76 | + path: nvflare.lighter.cc_provision.impl.onprem_packager.OnPremPackager |
| 77 | + args: |
| 78 | + build_image_cmd: build_cvm_image.sh |
43 | 79 | ``` |
44 | 80 |
|
45 | | -We have already prepared application-share folder and requirements.txt in this example. |
46 | | -We run the following command to create a zip folder so we can use that to build the CVM: |
| 81 | +Note: |
| 82 | + 1. `build_image_cmd`: Path to the script used to build the CVM disk image. |
| 83 | + 2. For 2.7.0 Technical Preview release, please contact `[email protected]` to receive the `build_cvm_image.sh` |
47 | 84 |
|
48 | | -```bash |
49 | | -python -m zipfile -c application_code.zip application_code/* |
50 | | -``` |
| 85 | +## 5. Generate the Startup Kits |
51 | 86 |
|
52 | | -# Content inside CC configuration |
| 87 | +Once you add all the required sections into your `project.yml`, run the provision command: |
53 | 88 |
|
| 89 | +```bash |
| 90 | +nvflare provision -p project.yml |
54 | 91 | ``` |
55 | | -compute_env: onprem_cvm |
56 | | -cc_cpu_mechanism: amd_sev_snp |
57 | | -role: server |
58 | 92 |
|
59 | | -# All drive sizes are in GB |
60 | | -root_drive_size: 15 |
61 | | -secure_drive_size: 2 |
62 | | -data_source: /tmp/data |
| 93 | +## 6. Distribute and deploy |
63 | 94 |
|
64 | | -# Can be any pip-installable version string (e.g., "2.6.0", "latest", Git URL, etc.) |
65 | | -nvflare_version: "2.6.0" |
| 95 | +Each site's result will be located in |
66 | 96 |
|
67 | | -# NVFlare application code package to be pre-installed inside the CVM |
68 | | -nvflare_package: application_code.zip |
69 | | -allowed_ports: |
70 | | - - 8002 |
71 | | -trustee_host: trustee-azsnptpm.eastus.cloudapp.azure.com |
72 | | -trustee_port: 8999 |
| 97 | +```bash |
| 98 | +workspace/example_project/prod_xx/[site_name]/[site_name].tgz |
| 99 | +``` |
73 | 100 |
|
74 | | -cc_issuers: |
75 | | - - id: snp_authorizer |
76 | | - path: nvflare.app_opt.confidential_computing.snp_authorizer.SNPAuthorizer |
77 | | - token_expiration: 150 # in seconds, needs to be less than check_frequency |
78 | | - - id: gpu_authorizer |
79 | | - path: nvflare.app_opt.confidential_computing.gpu_authorizer.GPUAuthorizer |
80 | | - token_expiration: 150 # in seconds, needs to be less than check_frequency |
| 101 | +You can distribute these tgz file to each site. |
81 | 102 |
|
82 | | -cc_attestation: |
83 | | - check_frequency: 300 # in seconds |
| 103 | +To deploy on each site, do: |
84 | 104 |
|
| 105 | +```bash |
| 106 | +tar -zxvf [site_name].tgz |
| 107 | +cd cvm_xxx |
| 108 | +./launch_vm.sh |
85 | 109 | ``` |
| 110 | + |
| 111 | +The confidential VM will start, and the NVFLARE server and clients will automatically connect and begin operation. |
| 112 | +You can now use the NVFlare admin console to communicate with the NVFlare system. |
0 commit comments