From 84290cbbf0c6e9a5de618c3fe6f452873eef24d8 Mon Sep 17 00:00:00 2001 From: KangqingYe Date: Sat, 19 Jun 2021 20:57:23 +0800 Subject: [PATCH] change gpu : by ykq --- .idea/workspace.xml | 38 +++++++++++++++++++------------------- main.py | 10 +++++++++- solver.py | 2 +- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7288dad..beb6088 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -16,8 +16,8 @@ - - + + @@ -28,8 +28,8 @@ - - + + @@ -40,7 +40,7 @@ - + @@ -169,7 +169,7 @@ - + @@ -177,7 +177,7 @@ - + @@ -199,16 +199,9 @@ - - - - - - - - + @@ -216,10 +209,17 @@ + + + + + + + - - + + @@ -228,8 +228,8 @@ - - + + diff --git a/main.py b/main.py index 8693d48..1f0a7fb 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,14 @@ from data_loader import get_loader from torch.backends import cudnn import random +import numpy as np + +os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" +os.system('nvidia-smi -q -d Memory |grep -A4 GPU|grep Free >tmp') +memory_gpu = [int(x.split()[2]) for x in open('tmp', 'r').readlines()] +print('Using GPU:' + str(np.argmax(memory_gpu))) +os.environ["CUDA_VISIBLE_DEVICES"] = str(np.argmax(memory_gpu)) +os.system('rm tmp') def main(config): cudnn.benchmark = True @@ -25,7 +33,7 @@ def main(config): lr = 0.0002 augmentation_prob= random.random()*0.7 # epoch = random.choice([100,150,200,250]) - epoch = 1 + epoch = 1000 decay_ratio = random.random()*0.8 decay_epoch = int(epoch*decay_ratio) diff --git a/solver.py b/solver.py index fbe34f7..f402e4e 100644 --- a/solver.py +++ b/solver.py @@ -297,7 +297,7 @@ def train(self): unloader = torchvision.transforms.ToPILImage() SR = unloader(SR) SR.save(os.path.join(self.result_path, - '%s_valid_%d_SR %d.png' % (self.model_type, epoch + 1, i))) + '%s_test_%d_SR %d.png' % (self.model_type, epoch + 1, i))) #torchvision.utils.save_image(GT.data.cpu(), # os.path.join(self.result_path,