diff --git a/Flower_v1/client_1.py b/Flower_v1/client_1.py index af26d00e8284e079351fa9bce9522c7b7248de22..8d0aed8cf23ca0b352e33a74b1dc3796b49f91c5 100644 --- a/Flower_v1/client_1.py +++ b/Flower_v1/client_1.py @@ -87,7 +87,7 @@ class FederatedClient(fl.client.NumPyClient): def fit(self, parameters, config): model.set_weights(parameters) - model.fit(x_train, y_train, epochs=5, batch_size=32, validation_data=(x_val, y_val)) + model.fit(x_train, y_train, epochs=1, batch_size=32, validation_data=(x_val, y_val)) return model.get_weights(), len(x_train), {} def evaluate(self, parameters, config): diff --git a/README.md b/README.md index 62c3af3012881a58bf46ebd191abdc2cfdd165c2..a9a03c06a5b0fb837ad5325b8236a1fc5729b8a1 100644 --- a/README.md +++ b/README.md @@ -188,16 +188,18 @@ cd Run ``` ### Step 2. Configure -Two JSON configuration files (e.g. `config_instances.json` for CPU and `config_instances_1.json` for GPU) to specify experiment details includes one or more instances. +Two JSON configuration files (e.g. `config_instances_CPU.json` for CPU and `config_instances_GPU.json` for GPU) to specify experiment details includes one or more instances. ```bash -cat config_instances.json +cat config_instances_CPU.json ``` -<u>For example</u>: `config_instances.json` provides two examples of instance configuration. All fields are configured except "`output_dir`" and "`args`" must be updated with your directories setting. +<u>For example</u>: `config_instances_CPU.json` provides two examples of instance configuration. - instance "`1`": fedAvg, cifar10, dvfs with min and max CPU freq, 1 round. - instance "`2`": fedAvg2Clients, cifar10, dvfs with min and max CPU freq, 1 round. +Total test time is about 5 minutes. + ### Step 3. Collect IP Run the following command to collect/generate a node list: @@ -207,19 +209,19 @@ uniq $OAR_NODEFILE > nodelist Automatically populate missing IP addresses in the JSON file: ```bash -python3 collect_ip.py -n nodelist -c config_instances.json +python3 collect_ip.py -n nodelist -c config_instances_CPU.json ``` ### Step 4. Run the Campaign or Single Instance Run single instance with instance `1`, and 2 repetitions: ```bash -python3 measure_instance.py -c config_instances.json -i 1 -x SingleTest -r 2 +python3 measure_instance.py -x SingleTest -c config_instances_CPU.json -i 1 -r 2 ``` Run a campaign with all instances (`1` and `2`), and 2 repetitions: ```bash -python3 measure_campaign.py -x CampaignTest -c config_instances.json -r 2 +python3 measure_campaign.py -x CampaignTest -c config_instances_CPU.json -r 2 ``` ### Step 5. Output @@ -229,10 +231,10 @@ The logs and energy monitoring data will be saved in the directory specified in Output dir structure: ```plaintext -/Flower_<x> -├── Flower_instance_<instance_name> +Log/Flower_CampaignTest +├── Flower_instance_Flower_instance_fedAvg_cifar10 │ ├── Expetator -| | ├── config_instance*.json +| | ├── config_instance_1.json │ ├── Expetator_<host_info>_<timestamp>_mojitos: mojitos outputs │ ├── Expetator_<host_info>_<timestamp>_power: wattmetter outputs │ ├── Expetator_<host_info>_<timestamp>: measurement log @@ -243,7 +245,8 @@ Output dir structure: │ ├── Flwr_<timestamp> │ │ ├── Client_<ip> │ │ ├── Server_<ip> -│── Flower_instance_<instance_name> +│── Flower_instance_Flower_instance_fedAvg2Clients_cifar10 +... ``` ### Step 6. Clean Up diff --git a/Run/config_instances.json b/Run/config_instances.json index b8bac0b373d5ca64667d26c2d6bbab31343db06a..924bd9b64111593e4bbb84de67acfc10532d731c 100644 --- a/Run/config_instances.json +++ b/Run/config_instances.json @@ -329,336 +329,6 @@ "ip": "172.16.66.79" } ] - }, - "7": { - "instance": "fedProx_cifar10", - "output_dir": "./Log", - "dvfs_cpu": { - "dummy": true, - "baseline": false, - "frequencies": null - }, - "server": { - "command": "python3", - "args": [ - "./Flower_v1/server_1.py", - "-r 1", - "-s fedProx" - ], - "ip": "172.16.66.76", - "modules": ["logger"], - "port": 8080 - }, - "clients": [ - { - "name": "client1", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar10", - "0", - "3" - ], - "ip": "172.16.66.77" - }, - { - "name": "client2", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar10", - "1", - "3" - ], - "ip": "172.16.66.78" - }, - { - "name": "client3", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar10", - "2", - "3" - ], - "ip": "172.16.66.79" - } - ] - }, - "8": { - "instance": "fedProx_cifar100", - "output_dir": "./Log", - "dvfs_cpu": { - "dummy": true, - "baseline": false, - "frequencies": null - }, - "server": { - "command": "python3", - "args": [ - "./Flower_v1/server_1.py", - "-r 1", - "-s fedProx" - ], - "ip": "172.16.66.76", - "modules": ["logger"], - "port": 8080 - }, - "clients": [ - { - "name": "client1", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar100", - "0", - "3" - ], - "ip": "172.16.66.77" - }, - { - "name": "client2", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar100", - "1", - "3" - ], - "ip": "172.16.66.78" - }, - { - "name": "client3", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar100", - "2", - "3" - ], - "ip": "172.16.66.79" - } - ] - }, - "9": { - "instance": "fedProx_mnist", - "output_dir": "./Log", - "dvfs_cpu": { - "dummy": true, - "baseline": false, - "frequencies": null - }, - "server": { - "command": "python3", - "args": [ - "./Flower_v1/server_1.py", - "-r 1", - "-s fedProx" - ], - "ip": "172.16.66.76", - "modules": ["logger"], - "port": 8080 - }, - "clients": [ - { - "name": "client1", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "mnist", - "0", - "3" - ], - "ip": "172.16.66.77" - }, - { - "name": "client2", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "mnist", - "1", - "3" - ], - "ip": "172.16.66.78" - }, - { - "name": "client3", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "mnist", - "2", - "3" - ], - "ip": "172.16.66.79" - } - ] - }, - "10": { - "instance": "fedAdam_cifar10", - "output_dir": "./Log", - "dvfs_cpu": { - "dummy": true, - "baseline": false, - "frequencies": null - }, - "server": { - "command": "python3", - "args": [ - "./Flower_v1/server_1.py", - "-r 1", - "-s fedAdam" - ], - "ip": "172.16.66.76", - "modules": ["logger"], - "port": 8080 - }, - "clients": [ - { - "name": "client1", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar10", - "0", - "3" - ], - "ip": "172.16.66.77" - }, - { - "name": "client2", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar10", - "1", - "3" - ], - "ip": "172.16.66.78" - }, - { - "name": "client3", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar10", - "2", - "3" - ], - "ip": "172.16.66.79" - } - ] - }, - "11": { - "instance": "fedAdam_cifar100", - "output_dir": "./Log", - "dvfs_cpu": { - "dummy": true, - "baseline": false, - "frequencies": null - }, - "server": { - "command": "python3", - "args": [ - "./Flower_v1/server_1.py", - "-r 1", - "-s fedAdam" - ], - "ip": "172.16.66.76", - "modules": ["logger"], - "port": 8080 - }, - "clients": [ - { - "name": "client1", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar100", - "0", - "3" - ], - "ip": "172.16.66.77" - }, - { - "name": "client2", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar100", - "1", - "3" - ], - "ip": "172.16.66.78" - }, - { - "name": "client3", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "cifar100", - "2", - "3" - ], - "ip": "172.16.66.79" - } - ] - }, - "12": { - "instance": "fedAdam_mnist", - "output_dir": "./Log", - "dvfs_cpu": { - "dummy": true, - "baseline": false, - "frequencies": null - }, - "server": { - "command": "python3", - "args": [ - "./Flower_v1/server_1.py", - "-r 1", - "-s fedAdam" - ], - "ip": "172.16.66.76", - "modules": ["logger"], - "port": 8080 - }, - "clients": [ - { - "name": "client1", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "mnist", - "0", - "3" - ], - "ip": "172.16.66.77" - }, - { - "name": "client2", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "mnist", - "1", - "3" - ], - "ip": "172.16.66.78" - }, - { - "name": "client3", - "command": "python3", - "args": [ - "./Flower_v1/client_1.py", - "mnist", - "2", - "3" - ], - "ip": "172.16.66.79" - } - ] } } -} +} \ No newline at end of file diff --git a/Run/config_instances_CPU.json b/Run/config_instances_CPU.json new file mode 100644 index 0000000000000000000000000000000000000000..86c1b1a6cc8e395c60221665bb60a9bbdcbf7550 --- /dev/null +++ b/Run/config_instances_CPU.json @@ -0,0 +1,114 @@ +{ + "instances": { + "1": { + "instance": "fedAvg_cifar10", + "output_dir": "./Log", + "dvfs_cpu": { + "dummy": true, + "baseline": false, + "frequencies": null + }, + "server": { + "command": "python3", + "args": [ + "./Flower_v1/server_1.py", + "-r 1", + "-s fedAvg" + ], + "ip": "172.16.66.76", + "modules": ["logger"], + "port": 8080 + }, + "clients": [ + { + "name": "client1", + "command": "python3", + "args": [ + "./Flower_v1/client_1.py", + "cifar10", + "0", + "3" + ], + "ip": "172.16.66.77" + }, + { + "name": "client2", + "command": "python3", + "args": [ + "./Flower_v1/client_1.py", + "cifar10", + "1", + "3" + ], + "ip": "172.16.66.78" + }, + { + "name": "client3", + "command": "python3", + "args": [ + "./Flower_v1/client_1.py", + "cifar10", + "2", + "3" + ], + "ip": "172.16.66.79" + } + ] + }, + "2": { + "instance": "fedAvg2Clients_cifar10", + "output_dir": "./Log", + "dvfs_cpu": { + "dummy": true, + "baseline": false, + "frequencies": null + }, + "server": { + "command": "python3", + "args": [ + "./Flower_v1/server_1.py", + "-r 1", + "-s fedAvg2Clients" + ], + "ip": "172.16.66.76", + "modules": ["logger"], + "port": 8080 + }, + "clients": [ + { + "name": "client1", + "command": "python3", + "args": [ + "./Flower_v1/client_1.py", + "cifar10", + "0", + "3" + ], + "ip": "172.16.66.77" + }, + { + "name": "client2", + "command": "python3", + "args": [ + "./Flower_v1/client_1.py", + "cifar10", + "1", + "3" + ], + "ip": "172.16.66.78" + }, + { + "name": "client3", + "command": "python3", + "args": [ + "./Flower_v1/client_1.py", + "cifar10", + "2", + "3" + ], + "ip": "172.16.66.79" + } + ] + } + } +} \ No newline at end of file diff --git a/Run/config_instances_1.json b/Run/config_instances_GPU.json similarity index 100% rename from Run/config_instances_1.json rename to Run/config_instances_GPU.json diff --git a/Run/measure_campaign.py b/Run/measure_campaign.py index 773d6315e6545b8c3a8e932520bf0b12a54367ea..0df626953edc55759a8f444f7da61c429154f054 100644 --- a/Run/measure_campaign.py +++ b/Run/measure_campaign.py @@ -22,7 +22,7 @@ def main(): args = parser.parse_args() # Path to the combined config.json file - config_path = parser.config + config_path = args.config # Read the config.json file try: diff --git a/Run/measure_instance.py b/Run/measure_instance.py index d1cf3b222760976928dc88f8b3d77c0065f160d4..73b2a7f17e5116337c8e9e2e79ec880ebd0a851a 100644 --- a/Run/measure_instance.py +++ b/Run/measure_instance.py @@ -5,7 +5,7 @@ import argparse import json import time import expetator.experiment as experiment -from expetator.monitors import Mojitos +from expetator.monitors import Mojitos, kwollect from expetator.leverages import Dvfs, GpuClock #import run_flwr as run_flwr @@ -99,6 +99,7 @@ if __name__ == "__main__": flower_log_dir, [DemoBench()], leverages= LEVERAGES, - monitors=[Mojitos(sensor_set={'user', 'rxp', 'dram0'})], + monitors=[Mojitos(sensor_set={'user', 'rxp', 'dram0'}), + kwollect.Power(metric=kwollect.get_g5k_target_metric())], times=args.repeat ) \ No newline at end of file