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 getting started notebooks for 2.5.0rc #2690

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,41 @@
"## Setup environment"
]
},
{
"cell_type": "markdown",
"id": "ebc38cbf",
"metadata": {},
"source": [
"Install nvflare and dependencies:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "33bba668-72ac-4e69-aaed-8d4254f547c0",
"metadata": {},
"outputs": [],
"source": [
"!pip install -q -r nvflare~=2.5.0rc pytorch_lightning"
"! pip install --ignore-installed blinker\n",
"! pip install nvflare~=2.5.0rc pytorch_lightning"
]
},
{
"cell_type": "markdown",
"id": "76354477",
"metadata": {},
"source": [
"If running in Google Colab, download the source code for this example:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7a382cae",
"metadata": {},
"outputs": [],
"source": [
"! npx degit NVIDIA/NVFlare/examples/getting_started/pt/src src"
]
},
{
Expand Down Expand Up @@ -386,7 +413,7 @@
" executor = ScriptExecutor(\n",
" task_script_path=\"src/cifar10_lightning_fl.py\", task_script_args=\"\" # f\"--batch_size 32 --data_path /tmp/data/site-{i}\"\n",
" )\n",
" job.to(executor, f\"site-{i}\", gpu=0)"
" job.to(executor, f\"site-{i+1}\", gpu=0)"
]
},
{
Expand Down Expand Up @@ -430,6 +457,24 @@
"source": [
"job.simulator_run(\"/tmp/nvflare/jobs/workdir\")"
]
},
{
"cell_type": "markdown",
"id": "3f56e377",
"metadata": {},
"source": [
"If using Google Colab and the output is not showing correctly, export the job and run it with the simulator command instead:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "52ed0d5d",
"metadata": {},
"outputs": [],
"source": [
"! nvflare simulator -w /tmp/nvflare/jobs/workdir -n 2 -t 2 -gpu 0 /tmp/nvflare/jobs/job_config/cifar10_fedavg_lightning"
]
}
],
"metadata": {
Expand Down
51 changes: 48 additions & 3 deletions examples/getting_started/pt/nvflare_pt_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,41 @@
"## Setup environment"
]
},
{
"cell_type": "markdown",
"id": "f5496ffe",
"metadata": {},
"source": [
"Install nvflare and dependencies:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "33bba668-72ac-4e69-aaed-8d4254f547c0",
"metadata": {},
"outputs": [],
"source": [
"!pip install -q -r nvflare~=2.5.0rc torch torchvision tensorboard"
"! pip install --ignore-installed blinker\n",
"! pip install nvflare~=2.5.0rc torch torchvision tensorboard"
]
},
{
"cell_type": "markdown",
"id": "baa517fe",
"metadata": {},
"source": [
"If running in Google Colab, download the source code for this example:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4c139be6",
"metadata": {},
"outputs": [],
"source": [
"! npx degit NVIDIA/NVFlare/examples/getting_started/pt/src src"
]
},
{
Expand Down Expand Up @@ -325,7 +352,7 @@
" executor = ScriptExecutor(\n",
" task_script_path=\"src/cifar10_fl.py\", task_script_args=\"\" # f\"--batch_size 32 --data_path /tmp/data/site-{i}\"\n",
" )\n",
" job.to(executor, f\"site-{i}\", gpu=0)"
" job.to(executor, f\"site-{i+1}\", gpu=0)"
]
},
{
Expand All @@ -336,7 +363,7 @@
"That's it!\n",
"\n",
"#### 6. Optionally export the job\n",
"Now, we could export the job and submit it to a real NVFlare deployment using the [Admin client](https://nvflare.readthedocs.io/en/main/real_world_fl/operation.html) or [FLARE API](https://nvflare.readthedocs.io/en/main/real_world_fl/flare_api.html). "
"Now, we could export the job and submit it to a real NVFlare deployment using the [Admin client](https://nvflare.readthedocs.io/en/main/real_world_fl/operation.html) or [FLARE API](https://nvflare.readthedocs.io/en/main/real_world_fl/flare_api.html)."
]
},
{
Expand Down Expand Up @@ -370,6 +397,24 @@
"job.simulator_run(\"/tmp/nvflare/jobs/workdir\")"
]
},
{
"cell_type": "markdown",
"id": "9ccbe893",
"metadata": {},
"source": [
"If using Google Colab and the output is not showing correctly, export the job and run it with the simulator command instead:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0e46a45d",
"metadata": {},
"outputs": [],
"source": [
"! nvflare simulator -w /tmp/nvflare/jobs/workdir -n 2 -t 2 -gpu 0 /tmp/nvflare/jobs/job_config/cifar10_fedavg"
]
},
{
"cell_type": "markdown",
"id": "f474ddfa-0d2e-4d7f-b033-8ccfbbd57a75",
Expand Down
49 changes: 47 additions & 2 deletions examples/getting_started/tf/nvflare_tf_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,41 @@
"## Setup environment"
]
},
{
"cell_type": "markdown",
"id": "7cc7e4d2",
"metadata": {},
"source": [
"Install nvflare and dependencies:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "33bba668-72ac-4e69-aaed-8d4254f547c0",
"metadata": {},
"outputs": [],
"source": [
"!pip install -q -r nvflare~=2.5.0rc tensorflow"
"! pip install --ignore-installed blinker\n",
"! pip install nvflare~=2.5.0rc tensorflow"
]
},
{
"cell_type": "markdown",
"id": "57945dcd",
"metadata": {},
"source": [
"If running in Google Colab, download the source code for this example:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "993b7696",
"metadata": {},
"outputs": [],
"source": [
"! npx degit NVIDIA/NVFlare/examples/getting_started/tf/src src"
]
},
{
Expand Down Expand Up @@ -321,7 +348,7 @@
" task_script_path=\"src/cifar10_tf_fl.py\", task_script_args=\"\" # f\"--batch_size 32 --data_path /tmp/data/site-{i}\"\n",
" params_exchange_format=ExchangeFormat.NUMPY,\n",
" )\n",
" job.to(executor, f\"site-{i}\", gpu=0)"
" job.to(executor, f\"site-{i+1}\", gpu=0)"
]
},
{
Expand Down Expand Up @@ -365,6 +392,24 @@
"source": [
"job.simulator_run(\"/tmp/nvflare/jobs/workdir\")"
]
},
{
"cell_type": "markdown",
"id": "44ee8632",
"metadata": {},
"source": [
"If using Google Colab and the output is not showing correctly, export the job and run it with the simulator command instead:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7ec915ec",
"metadata": {},
"outputs": [],
"source": [
"! nvflare simulator -w /tmp/nvflare/jobs/workdir -n 2 -t 2 -gpu 0 /tmp/nvflare/jobs/job_config/cifar10_tf_fedavg"
]
}
],
"metadata": {
Expand Down
Loading