Skip to content
Snippets Groups Projects
Commit 7d728af6 authored by huongdm1896's avatar huongdm1896
Browse files

add GPU

parent 93694e7b
Branches
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ This project provides tools to measure the energy consumption of Flower-based fe
- [Installation](#installation)
- [Usage](#usage)
- [FL framework](#fl-framework)
- [Configure instances](#configure-instance)
- [Configure instances for CPU](#configure-instance-for-cpu)
- [Run exp](#run-exp)
- [Quickstart](#quickstart)
- [Step 1. Reserve the Hosts in G5K](#step-1-reserve-the-hosts-in-g5k)
......@@ -51,13 +51,13 @@ cd Run
### FL framework
FL scripts (includes server and client scripts) can be updated, example in dir `Flower_v1`.
### Configure instance
### Configure instance for CPU
Configure instances of experiment in a json format, structure is shown below.
- **instances** includes **"1"**, **"2"** ,... are identifies of each instance.
- **instance**: name of instance.
- **output_dir**: location stores the output files (experiment log and energy monitoring output).
- **dvfs**: choose only one in 3 settings, detects all available CPU frequencies and go through all of them.
- **dvfs_cpu**: choose only one in 3 settings.
- `dummy`: for testing in min and max CPU freq (`false` or `true`).
- `baseline`: for testing in max CPU freq (`false` or `true`).
- `frequencies`: Limits to the provided list of frequencies (`null` or `int list []`).
......@@ -80,7 +80,7 @@ Configure instances of experiment in a json format, structure is shown below.
"1": {
"instance": "",
"output_dir": "",
"dvfs": {
"dvfs_cpu": {
"dummy": true,
"baseline": false,
"frequencies": null
......@@ -112,6 +112,25 @@ Configure instances of experiment in a json format, structure is shown below.
}
```
### Configure instance for GPU
- The configuration is as same CPU, except **dvfs** role. In GPU config, the role is **dvfs_gpu**.
Choose only one in 3 settings (steps - zoomfrom - zoomto use for one setting).
- `dummy`: for testing in min and max GPU freq (`false` or `true`).
- `baseline`: for testing in max GPU freq (`false` or `true`).
- `steps`: steps to jump in range/window of frequencies (int).
- `zoomfrom`: freq start
- `zoomto`: freq stop
```json
"dvfs_gpu": {
"dummy": true,
"baseline": false,
"steps": 2,
"zoomfrom": 0,
"zoomto": 0
},
```
### Run exp
2 options of experiment: run single instance or all instances (a campaign).
......@@ -137,17 +156,25 @@ Configure instances of experiment in a json format, structure is shown below.
### Step 1. Reserve the Hosts in G5K
Reserve the required number of hosts (*See the [document of G5K](https://www.grid5000.fr/w/Getting_Started#Reserving_resources_with_OAR:_the_basics) for more details*)
<u>For example</u>: Reserve 4 hosts (1 server + 3 clients) for 2 hours:
<u>For example</u>:
Reserve 4 hosts (CPU) (1 server + 3 clients) for 2 hours:
```bash
oarsub -I -l host=4,walltime=2
```
Reserve 4 hosts (GPU) (1 server + 3 clients) for 2 hours:
```bash
oarsub -p "gpu_count>0" -l host=4,walltime=2 -t exotic -I #lyon
oarsub -p "gpu_count>0" -l host=4,walltime=2 -I #lille
```
Make sure your are in`eflwr/Run/`:
```bash
cd Run
```
### Step 2. Configure
Create the JSON configuration file (e.g. `config_instances.json`) to specify experiment details includes one or more instances.
Create the JSON configuration file (e.g. `config_instances.json` for CPU and `config_instances_1.json` for GPU) to specify experiment details includes one or more instances.
```bash
vim config_instances.json
......
......@@ -3,7 +3,7 @@
"1": {
"instance": "fedAvg_cifar10",
"output_dir": "/home/mdo/Framework/eflwr/Log",
"dvfs": {
"dvfs_cpu": {
"dummy": true,
"baseline": false,
"frequencies": null
......@@ -57,7 +57,7 @@
"2": {
"instance": "fedAvg2Clients_cifar10",
"output_dir": "/home/mdo/Framework/eflwr/Log",
"dvfs": {
"dvfs_cpu": {
"dummy": true,
"baseline": false,
"frequencies": null
......
{
"instances": {
"1": {
"instance": "fedAvg_cifar10",
"output_dir": "/home/mdo/Framework/eflwr/Log",
"dvfs_gpu": {
"dummy": true,
"baseline": false,
"steps": 2,
"zoomfrom": 0,
"zoomto": 0
},
"server": {
"command": "python3",
"args": [
"/home/mdo/Framework/eflwr/Flower_v1/server_1.py",
"-r 1",
"-s fedAvg"
],
"ip": "172.16.66.76",
"port": 8080
},
"clients": [
{
"name": "client1",
"command": "python3",
"args": [
"/home/mdo/Framework/eflwr/Flower_v1/client_1.py",
"cifar10",
"1",
"3"
],
"ip": "172.16.66.77"
},
{
"name": "client2",
"command": "python3",
"args": [
"/home/mdo/Framework/eflwr/Flower_v1/client_1.py",
"cifar10",
"2",
"3"
],
"ip": "172.16.66.78"
},
{
"name": "client3",
"command": "python3",
"args": [
"/home/mdo/Framework/eflwr/Flower_v1/client_1.py",
"cifar10",
"3",
"3"
],
"ip": "172.16.66.79"
}
]
},
"2": {
"instance": "fedAvg2Clients_cifar10",
"output_dir": "/home/mdo/Framework/eflwr/Log",
"dvfs_gpu": {
"dummy": true,
"baseline": false,
"steps": 2,
"zoomfrom": 0,
"zoomto": 0
},
"server": {
"command": "python3",
"args": [
"/home/mdo/Framework/eflwr/Flower_v1/server_1.py",
"-r 1",
"-s fedAvg2Clients"
],
"ip": "172.16.66.76",
"port": 8080
},
"clients": [
{
"name": "client1",
"command": "python3",
"args": [
"/home/mdo/Framework/eflwr/Flower_v1/client_1.py",
"cifar10",
"1",
"3"
],
"ip": "172.16.66.77"
},
{
"name": "client2",
"command": "python3",
"args": [
"/home/mdo/Framework/eflwr/Flower_v1/client_1.py",
"cifar10",
"2",
"3"
],
"ip": "172.16.66.78"
},
{
"name": "client3",
"command": "python3",
"args": [
"/home/mdo/Framework/eflwr/Flower_v1/client_1.py",
"cifar10",
"3",
"3"
],
"ip": "172.16.66.79"
}
]
}
}
}
......@@ -6,7 +6,7 @@ import json
import time
import expetator.experiment as experiment
from expetator.monitors import Mojitos
from expetator.leverages import Dvfs
from expetator.leverages import Dvfs, GpuClock
#import run_flwr as run_flwr
# Set up argument parser
......@@ -37,13 +37,27 @@ if instance_key not in config_data["instances"]:
# Load config instance
config = config_data["instances"][instance_key]
# Extract DVFS from config
dvfs_config = config.get("dvfs", {})
dvfs = Dvfs(
dummy=dvfs_config.get("dummy", False),
baseline=dvfs_config.get("baseline", False),
frequencies=dvfs_config.get("frequencies", None)
)
# extract DVFS infor (cpu and gpu)
if "dvfs_cpu" in config:
dvfs_config = config["dvfs_cpu"]
dvfs = Dvfs(
dummy=dvfs_config.get("dummy", False),
baseline=dvfs_config.get("baseline", False),
frequencies=dvfs_config.get("frequencies", None)
)
LEVERAGES = [dvfs]
elif "dvfs_gpu" in config:
dvfs_config = config["dvfs_gpu"]
dvfs = GpuClock(
dummy=dvfs_config.get("dummy", False),
baseline=dvfs_config.get("baseline", False),
steps=dvfs_config.get("steps", 2),
zoomfrom=dvfs_config.get("zoomfrom", 0),
zoomto=dvfs_config.get("zoomto", 0)
)
LEVERAGES = [dvfs]
else:
LEVERAGES = []
# Log directory
log_dir = config["output_dir"]
......@@ -78,7 +92,7 @@ if __name__ == "__main__":
experiment.run_experiment(
flower_log_dir,
[DemoBench()],
leverages=[dvfs],
leverages= LEVERAGES,
monitors=[Mojitos(sensor_set={'user', 'rxp', 'dram0'})],
times=args.repeat
)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment