Skip to content

Commit

Permalink
change gpu : by ykq
Browse files Browse the repository at this point in the history
  • Loading branch information
KangqingYe committed Jun 19, 2021
1 parent 74c190c commit 84290cb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
38 changes: 19 additions & 19 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 84290cb

Please sign in to comment.