Skip to content

Commit 4afda1d

Browse files
author
um1
committed
remove compile
1 parent d8b906f commit 4afda1d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

test.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,11 @@ def load_network(network):
164164
try:
165165
network.load_state_dict(torch.load(save_path))
166166
except:
167-
if torch.cuda.get_device_capability()[0]>6 and len(opt.gpu_ids)==1 and int(version[0])>1: # should be >=7
168-
print("Compiling model...")
167+
#if torch.cuda.get_device_capability()[0]>6 and len(opt.gpu_ids)==1 and int(version[0])>1: # should be >=7
168+
#print("Compiling model...")
169169
# https://huggingface.co/docs/diffusers/main/en/optimization/torch2.0
170-
torch.set_float32_matmul_precision('high')
171-
network.cuda()
172-
network = torch.compile(network, mode="reduce-overhead", dynamic = True) # pytorch 2.0
170+
#torch.set_float32_matmul_precision('high')
171+
#network = torch.compile(network, mode="reduce-overhead", dynamic = True) # pytorch 2.0
173172
if 'average' in opt.which_epoch: # load averaged model.
174173
network = swa_utils.AveragedModel(network)
175174
network.load_state_dict(torch.load(save_path))

train.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@ def train_model(model, criterion, optimizer, scheduler, num_epochs=25):
229229
wa_flag = opt.wa
230230
warm_up = 0.1 # We start from the 0.1*lrRate
231231
warm_iteration = round(dataset_sizes['train']/opt.batchsize)*opt.warm_epoch # first 5 epoch
232-
embedding_size = model.classifier.linear_num
232+
if opt.PCB:
233+
embedding_size = model.classifier0.linear_num
234+
else:
235+
embedding_size = model.classifier.linear_num
233236
if opt.arcface:
234237
criterion_arcface = losses.ArcFaceLoss(num_classes=opt.nclasses, embedding_size=embedding_size)
235238
if opt.cosface:
@@ -533,11 +536,11 @@ def draw_curve(current_epoch):
533536
if opt.FSGD: # apex is needed
534537
optim_name = FusedSGD
535538

536-
if torch.cuda.get_device_capability()[0]>6 and len(opt.gpu_ids)==1 and int(version[0])>1: # should be >=7 and one gpu
537-
torch.set_float32_matmul_precision('high')
538-
print("Compiling model... The first epoch may be slow, which is expected!")
539+
#if torch.cuda.get_device_capability()[0]>6 and len(opt.gpu_ids)==1 and int(version[0])>1: # should be >=7 and one gpu
540+
#torch.set_float32_matmul_precision('high')
541+
#print("Compiling model... The first epoch may be slow, which is expected!")
539542
# https://huggingface.co/docs/diffusers/main/en/optimization/torch2.0
540-
model = torch.compile(model, mode="reduce-overhead", dynamic = True) # pytorch 2.0
543+
#model = torch.compile(model, mode="reduce-overhead", dynamic = True) # pytorch 2.0
541544

542545
if len(opt.gpu_ids)>1:
543546
model = torch.nn.DataParallel(model, device_ids=opt.gpu_ids)

0 commit comments

Comments
 (0)