FedLab icon indicating copy to clipboard operation
FedLab copied to clipboard

Got this error i am trying to running the example standalone-mnist

Open ibad321 opened this issue 1 year ago • 20 comments

Fedlab version =1.3.0 python version =Python 3.10.12 torch=1.7.1 torchvision=0.8.2 No Gpu i am running on laptop corei5 12th Generation Cpu

Got the below error when i try to run example standalone-minist Screenshot from 2024-08-11 12-33-29

ibad321 avatar Aug 11 '24 12:08 ibad321

Hi, please see this issue: https://github.com/SMILELab-FL/FedLab/issues/352

dunzeng avatar Aug 11 '24 13:08 dunzeng

Hi, please see this issue: #352

thanks for response i did this changes but the error Remain same i am using Ubuntu OS and i have no Gpu on working Machine

Here is below Screen shot Screenshot from 2024-08-11 14-43-32 Screenshot from 2024-08-11 14-44-11

ibad321 avatar Aug 11 '24 14:08 ibad321

Please set cuda=False at line 41 for the server handler.

dunzeng avatar Aug 11 '24 14:08 dunzeng

Please set cuda=False at line 41 for the server handler.

Thanks Again for response Now give this error when i did the above changes. Screenshot from 2024-08-11 14-54-18 Screenshot from 2024-08-11 14-56-46

ibad321 avatar Aug 11 '24 14:08 ibad321

Please set cuda=False at line 41 for the server handler.

Thanks Again for response Now give this error when i did the above changes. Screenshot from 2024-08-11 14-54-18 Screenshot from 2024-08-11 14-56-46

This is a bit weird cause we have set cuda=False as default for the server handler in our codes. Could you please just remove the cuda=False part in line 41? Then save the script and run the launch.sh again. Let's see what happens.

dunzeng avatar Aug 11 '24 15:08 dunzeng

Please set cuda=False at line 41 for the server handler.

Thanks Again for response Now give this error when i did the above changes. Screenshot from 2024-08-11 14-54-18 Screenshot from 2024-08-11 14-56-46

This is a bit weird cause we have set cuda=False as default for the server handler in our codes. Could you please just remove the cuda=False part in line 41? Then save the script and run the launch.sh again. Let's see what happens.

Thanks for response i did the change but issue not resolved Here below is Screenshot Screenshot from 2024-08-11 15-14-18 Screenshot from 2024-08-11 15-15-07

ibad321 avatar Aug 11 '24 15:08 ibad321

It seems to be a bug. I am working on fixing it. Please replace the standalone.py with the codes below and rerun it:

from json import load
import os
import argparse
import random
from copy import deepcopy
import torchvision
import torchvision.transforms as transforms
from torch import nn
import sys
import torch

sys.path.append("../../")
torch.manual_seed(0)

from fedlab.utils.aggregator import Aggregators
from fedlab.utils.serialization import SerializationTool
from fedlab.utils.functional import evaluate, get_best_gpu

from fedlab.models.mlp import MLP
from fedlab.contrib.algorithm.basic_server import SyncServerHandler
from fedlab.contrib.algorithm.basic_client import SGDSerialClientTrainer
from fedlab.core.standalone import StandalonePipeline
from fedlab.contrib.dataset.pathological_mnist import PathologicalMNIST

# configuration
parser = argparse.ArgumentParser(description="Standalone training example")
parser.add_argument("--total_clients", type=int, default=100)
parser.add_argument("--com_round", type=int)

parser.add_argument("--sample_ratio", type=float)
parser.add_argument("--batch_size", type=int)
parser.add_argument("--epochs", type=int)
parser.add_argument("--lr", type=float)

args = parser.parse_args()

model = MLP(784, 10)

# server
handler = SyncServerHandler(
    model, args.com_round, args.sample_ratio
)

# client
trainer = SGDSerialClientTrainer(model, args.total_clients, cuda=False)
dataset = PathologicalMNIST(
    root="../../datasets/mnist/",
    path="../../datasets/mnist/",
    num_clients=args.total_clients,
)
dataset.preprocess()

trainer.setup_dataset(dataset)
trainer.setup_optim(args.epochs, args.batch_size, args.lr)

handler.num_clients = args.total_clients
handler.setup_dataset(dataset)
# main
pipeline = StandalonePipeline(handler, trainer)
pipeline.main()

dunzeng avatar Aug 11 '24 15:08 dunzeng

It seems to be a bug. I am working on fixing it. Please replace the standalone.py with the codes below and rerun it:

from json import load
import os
import argparse
import random
from copy import deepcopy
import torchvision
import torchvision.transforms as transforms
from torch import nn
import sys
import torch

sys.path.append("../../")
torch.manual_seed(0)

from fedlab.utils.aggregator import Aggregators
from fedlab.utils.serialization import SerializationTool
from fedlab.utils.functional import evaluate, get_best_gpu

from fedlab.models.mlp import MLP
from fedlab.contrib.algorithm.basic_server import SyncServerHandler
from fedlab.contrib.algorithm.basic_client import SGDSerialClientTrainer
from fedlab.core.standalone import StandalonePipeline
from fedlab.contrib.dataset.pathological_mnist import PathologicalMNIST

# configuration
parser = argparse.ArgumentParser(description="Standalone training example")
parser.add_argument("--total_clients", type=int, default=100)
parser.add_argument("--com_round", type=int)

parser.add_argument("--sample_ratio", type=float)
parser.add_argument("--batch_size", type=int)
parser.add_argument("--epochs", type=int)
parser.add_argument("--lr", type=float)

args = parser.parse_args()

model = MLP(784, 10)

# server
handler = SyncServerHandler(
    model, args.com_round, args.sample_ratio
)

# client
trainer = SGDSerialClientTrainer(model, args.total_clients, cuda=False)
dataset = PathologicalMNIST(
    root="../../datasets/mnist/",
    path="../../datasets/mnist/",
    num_clients=args.total_clients,
)
dataset.preprocess()

trainer.setup_dataset(dataset)
trainer.setup_optim(args.epochs, args.batch_size, args.lr)

handler.num_clients = args.total_clients
handler.setup_dataset(dataset)
# main
pipeline = StandalonePipeline(handler, trainer)
pipeline.main()

Thanks Again for Responce i did the changes mean copy the standalone.py and Paste Now give me the below error And Here is Line 57 Code handler.setup_dataset(dataset) ###main pipeline = StandalonePipeline(handler, trainer) pipeline.main()

Screenshot from 2024-08-11 16-53-46 Screenshot from 2024-08-11 17-29-05

ibad321 avatar Aug 11 '24 16:08 ibad321

Sorry for the late reply.

The example codes are adapted to the latest version of FedLab. Please try download the source code of the main branch and run it locally.

dunzeng avatar Aug 12 '24 03:08 dunzeng

Sorry for the late reply.

The example codes are adapted to the latest version of FedLab. Please try download the source code of the main branch and run it locally.

Thanks for responce we download the aource code from release-v1.3.0 and than inside the examples/standalone-mnist/standalone.py change 41 line to cuda = False due to no Gpu now give this output what is mean As it successfully run or Again issue. Here is Screen shot Screenshot from 2024-08-12 05-51-12

ibad321 avatar Aug 12 '24 06:08 ibad321

Please try the master branch via git clone https://github.com/SMILELab-FL/FedLab.git

dunzeng avatar Aug 12 '24 06:08 dunzeng

Please try the master branch via git clone https://github.com/SMILELab-FL/FedLab.git

Thanks for Responce Now i clone Exit the link git clone https://github.com/SMILELab-FL/FedLab.git and then installed the requiremnt pip install -r requirements.txt and than pip install fedlab==1.3.0 and no changes same thing run and Got this error. Note cuda=False when when we exute the code Here is below screen Shot Screenshot from 2024-08-12 06-17-14

ibad321 avatar Aug 12 '24 06:08 ibad321

Please do not run pip install fedlab==1.3.0. Because you have downloaded the source code. Just run the script directly.

dunzeng avatar Aug 12 '24 06:08 dunzeng

Please do not run pip install fedlab==1.3.0. Because you have downloaded the source code. Just run the script directly.

Thanks again for response Now i delete the old folder and create new folder inside new folder clone the git clone https://github.com/SMILELab-FL/FedLab.git and the requirement are already installed in our system and did not exute this command as follow your instruction pip install fedlab==1.3.0 but Again same Issue you can see the folder name on Screen shot Here is Screen shot of New folder Screenshot from 2024-08-12 06-32-40

ibad321 avatar Aug 12 '24 06:08 ibad321

Please replace line 57 with handler.dataset = dataset

dunzeng avatar Aug 12 '24 06:08 dunzeng

handler.dataset = dataset

Thanks for response when i change the line57 got this output As this is actual Output or Some issue again Screenshot from 2024-08-12 06-42-11

ibad321 avatar Aug 12 '24 06:08 ibad321

It works for me. Please make sure you have removed fedlab 1.3.0 from your python env.

image

dunzeng avatar Aug 12 '24 06:08 dunzeng

It works for me. Please make sure you have removed fedlab 1.3.0 from your python env. image

Thanks Again for your responce i follow your Instruction now give this output Screenshot from 2024-08-12 08-19-31 Screenshot from 2024-08-12 08-19-36

ibad321 avatar Aug 12 '24 08:08 ibad321

It works for me. Please make sure you have removed fedlab 1.3.0 from your python env. image

Thanks if this issue resolve i paste the Screenshot above Comment Please solve look it the #355 Issue Its give the same Error When we follow the Above Instruction.

ibad321 avatar Aug 12 '24 09:08 ibad321

@dunzeng Thanks If the Issue is Resolved and my output is Correct than i closed the issue.

ibad321 avatar Aug 13 '24 09:08 ibad321