# Nvflare 安裝說明
## Simulator
### 1. 安裝 Anaconda
https://www.anaconda.com/products/distribution
### 2. 創建一個conda環境並安裝nvflare套件 (python版本: 3.8)
```shell=
conda create --name <env_name> python=3.8
conda activate <env_name>
python3 -m pip install nvflare
```
### 3. 使用指令直接啟動訓練
範例:
```shell=
nvflare simulator NVFlare/examples/hello-numpy-sag/app -w /tmp/nvflare/workspace_folder/ -n 8 -t 1
```
相關參數用法可以參考官網的介紹
## Provision
### 1. 安裝 Anaconda
https://www.anaconda.com/products/distribution
### 2. 創建一個conda環境並安裝nvflare套件 (python版本: 3.8)
```shell=
conda create --name <env_name> python=3.8
conda activate <env_name>
python3 -m pip install nvflare
mkdir workspace
cd workspace
```
### 3. 創建和設定 project.yml
```yml=
api_version: 3
name: example_project
description: NVIDIA FLARE sample project yaml file
participants:
# change example.com to the FQDN of the server
- name: server1
type: server
org: nvidia
fed_learn_port: 8002
admin_port: 8003
- name: site-1
type: client
org: nvidia
- name: site-2
type: client
org: nvidia
- name: admin@nvidia.com
type: admin
org: nvidia
role: project_admin
# The same methods in all builders are called in their order defined in builders section
builders:
- path: nvflare.lighter.impl.workspace.WorkspaceBuilder
args:
template_file: master_template.yml
- path: nvflare.lighter.impl.template.TemplateBuilder
- path: nvflare.lighter.impl.static_file.StaticFileBuilder
args:
# config_folder can be set to inform NVIDIA FLARE where to get configuration
config_folder: config
# app_validator is used to verify if uploaded app has proper structures
# if not set, no app_validator is included in fed_server.json
# app_validator: PATH_TO_YOUR_OWN_APP_VALIDATOR
# when docker_image is set to a docker image name, docker.sh will be generated on server/client/admin
# docker_image:
# download_job_url is set to http://download.server.com/ as default in fed_server.json. You can override this
# to different url.
# download_job_url: http://download.server.com/
overseer_agent:
path: nvflare.ha.dummy_overseer_agent.DummyOverseerAgent
# if overseer_exists is true, args here are ignored. Provisioning
# tool will fill role, name and other local parameters automatically.
# if overseer_exists is false, args in this section will be used and the sp_end_point
# must match the server defined above in the format of SERVER_NAME:FL_PORT:ADMIN_PORT
#
overseer_exists: false
args:
sp_end_point: server1:8002:8003
- path: nvflare.lighter.impl.cert.CertBuilder
- path: nvflare.lighter.impl.signature.SignatureBuilder
```
### 4. 使用指令產生工作區
```shell=
nvflare provision
```
底下即可看到產生出的存放的server和client的資料夾
## Reference
https://nvflare.readthedocs.io/en/2.2.1/index.html