diff --git a/README.md b/README.md index c49ae53..0b7e33c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ These dockerfiles will also be pushed and actively maintained in their original | VLA | [`OpenVLA`](packages/vla/openvla), [`SmolVLA`](packages/vla/smolvla), [`GR00T-N1.5`](packages/vla/gr00t), [`openpi`](packages/vla/openpi), [`CogACT`](packages/vla/cogact) | | Graphics | [`O3DE`](packages/graphics/o3de) | | Robotics | [`ROS 2`](packages/ros/ros), [`Gazebo`](packages/ros/gazebo), [`LeRobot`](packages/robotics/lerobot), [`ACT`](packages/robotics/act), [`RAI`](packages/robotics/rai) | +| Federated Learning | [`Flower`](packages/federated/flower) | | Simulation | [`Genesis`](packages/robotics/genesis) | | Vision | [`OpenCV`](packages/vision/opencv), [`SAM`](packages/vision/sam), [`MobileSAM`](packages/vision/mobilesam), [`ncnn`](packages/vision/ncnn), [`DINOv3`](packages/vision/dinov3), [`SAM3`](packages/vision/sam3), [`Ultralytics`](packages/vision/ultralytics) | | Ryzen AI NPU | [`XDNA`](packages/npu/xdna), [`IRON`](packages/npu/iron), [`NPUEval`](packages/npu/npueval), [`Ryzen AI CVML`](packages/npu/ryzenai_cvml) | diff --git a/packages/federated/flower/Dockerfile b/packages/federated/flower/Dockerfile new file mode 100644 index 0000000..f9ad85d --- /dev/null +++ b/packages/federated/flower/Dockerfile @@ -0,0 +1,17 @@ +# Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: MIT + +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +WORKDIR /ryzers + +RUN pip install -U "flwr[simulation]" + +RUN flwr new @flwrlabs/quickstart-pytorch +RUN cd quickstart-pytorch && sed -i '/torch=/d;/torchvision=/d' pyproject.toml && pip install -e . + + +COPY test.sh . +RUN chmod +x test.sh +CMD ./test.sh diff --git a/packages/federated/flower/README.md b/packages/federated/flower/README.md new file mode 100644 index 0000000..888fa65 --- /dev/null +++ b/packages/federated/flower/README.md @@ -0,0 +1,46 @@ +# Flower +Flower is a framework for federated learning. This Ryzer demonstrates how to use Flower on AMD GPUs. This example is based on the Flower example found [here](https://flower.ai/docs/framework/docker/tutorial-quickstart-docker.html). + +## Install Flower +Execute `pip install flower` to install Flower. + +In `Ryzers/packages/federated/superexec/` create a getting started project: +``` +flwr new @flwrlabs/quickstart-pytorch +``` + +Edit the `pyproject.toml` to comment out the dependencies on torch and torchvision (lines 13-14), as these packages are installed in the Ryzer already. + +## Build the containers +Unlike other Ryzers, Flower requires several containers to be built. From the Ryzers directory, run; + +``` +ryzers build superexec --name superexec +ryzers build superlink --name superlink +ryzers build supernode --name supernode +``` + +## Create the network +Flower communicates between the containers using the docker network. Create a dedicated docker network for it to use: +``` +docker network create --driver bridge flwr-network +``` + +## Run the example +Run `Ryzers/packages/federated/superexec/flower.sh`. This will launch a superlink to coordinate the federation, supernodes (clients), and superexecs for scheduling applications per client. + +Find your local config file: +`flwr config list` + +Edit the config file to tell it about your superlink: +``` +[superlink.local-deployment] +address = "127.0.0.1:9093" +insecure = true +``` + +Launch the quickstart application with 2 clients: + +`flwr run . local-deployment --stream` + +The example will use the GPU between 2 clients. diff --git a/packages/federated/flower/config.yaml b/packages/federated/flower/config.yaml new file mode 100644 index 0000000..3c34ef6 --- /dev/null +++ b/packages/federated/flower/config.yaml @@ -0,0 +1,2 @@ +# Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: MIT diff --git a/packages/federated/flower/superexec/Dockerfile b/packages/federated/flower/superexec/Dockerfile new file mode 100644 index 0000000..11e6c31 --- /dev/null +++ b/packages/federated/flower/superexec/Dockerfile @@ -0,0 +1,17 @@ +# Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: MIT + +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +ENV HSA_OVERRIDE_GFX_VERSION=11.0.0 + +WORKDIR /ryzers + +RUN python -m pip install flwr + +COPY quickstart-pytorch/pyproject.toml . +RUN sed -i 's/.*flwr\[simulation\].*//' pyproject.toml \ +&& python -m pip install -U --no-cache-dir . + +ENTRYPOINT ["flower-superexec"] diff --git a/packages/federated/flower/superexec/flower.sh b/packages/federated/flower/superexec/flower.sh new file mode 100755 index 0000000..e134235 --- /dev/null +++ b/packages/federated/flower/superexec/flower.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +docker run --rm -p 9091:9091 -p 9092:9092 -p 9093:9093 --shm-size 16G --cap-add=SYS_PTRACE --network=flwr-network --ipc=host --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video --group-add render -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/video0 --device /dev/video1 --name superlink --detach superlink --insecure --isolation process + +docker run --rm -p 9095:9095 --name supernode-2 --detach --shm-size 16G --cap-add=SYS_PTRACE --network=flwr-network --ipc=host --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video --group-add render -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/video0 --device /dev/video1 supernode --insecure --superlink superlink:9092 --node-config "partition-id=0 num-partitions=2" --clientappio-api-address 0.0.0.0:9095 --isolation process + +docker run --rm -p 9094:9094 --name supernode-1 --detach --shm-size 16G --cap-add=SYS_PTRACE --network=flwr-network --ipc=host --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video --group-add render -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/video0 --device /dev/video1 supernode --insecure --superlink superlink:9092 --node-config "partition-id=0 num-partitions=2" --clientappio-api-address 0.0.0.0:9094 --isolation process + +docker run --rm --name superexec-serverapp --detach --shm-size 16G --cap-add=SYS_PTRACE --network=flwr-network --ipc=host --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video --group-add render -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/video0 --device /dev/video1 superexec --insecure --plugin-type serverapp --appio-api-address superlink:9091 + +docker run --rm --name superexec-clientapp-1 --shm-size 16G --cap-add=SYS_PTRACE --network=flwr-network --ipc=host --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video --group-add render -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/video0 --device /dev/video1 --detach superexec --insecure --plugin-type clientapp --appio-api-address supernode-1:9094 + +docker run --rm --name superexec-clientapp-2 --shm-size 16G --cap-add=SYS_PTRACE --network=flwr-network --ipc=host --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video --group-add render -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --device /dev/video0 --device /dev/video1 --detach superexec --insecure --plugin-type clientapp --appio-api-address supernode-2:9095 diff --git a/packages/federated/flower/superlink/Dockerfile b/packages/federated/flower/superlink/Dockerfile new file mode 100644 index 0000000..bef8f4f --- /dev/null +++ b/packages/federated/flower/superlink/Dockerfile @@ -0,0 +1,15 @@ +# Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: MIT + +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +WORKDIR /ryzers + + +ENV HSA_OVERRIDE_GFX_VERSION=11.0.0 + + +RUN python -m pip install flwr + +ENTRYPOINT ["flower-superlink"] diff --git a/packages/federated/flower/supernode/Dockerfile b/packages/federated/flower/supernode/Dockerfile new file mode 100644 index 0000000..98af485 --- /dev/null +++ b/packages/federated/flower/supernode/Dockerfile @@ -0,0 +1,13 @@ +# Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: MIT + +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +WORKDIR /ryzers + +ENV HSA_OVERRIDE_GFX_VERSION=11.0.0 + +RUN python -m pip install flwr + +ENTRYPOINT ["flower-supernode"] diff --git a/packages/federated/flower/test.sh b/packages/federated/flower/test.sh new file mode 100644 index 0000000..9d08171 --- /dev/null +++ b/packages/federated/flower/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: MIT + +python -c "import flwr;print('flwr version:', flwr.__version__)" diff --git a/ryzers/packages.py b/ryzers/packages.py index 3fce431..851f6bb 100644 --- a/ryzers/packages.py +++ b/ryzers/packages.py @@ -50,8 +50,8 @@ def _find_allpackages(self, current_path=None, current_depth=0, max_depth=4): if self._is_directory_readable(entry_path): if os.path.exists(os.path.join(entry_path, "Dockerfile")): dockerfile_path_map[entry] = entry_path - else: - dockerfile_path_map.update(self._find_allpackages(entry_path, current_depth + 1, max_depth)) + #else: + dockerfile_path_map.update(self._find_allpackages(entry_path, current_depth + 1, max_depth)) return dockerfile_path_map def get_packages_filelist(self, filename, optional=False): @@ -94,4 +94,4 @@ def get_initial_image(self): def _is_directory_readable(self, path): return (os.path.exists(path) and os.path.isdir(path) and - os.access(path, os.R_OK)) \ No newline at end of file + os.access(path, os.R_OK))