File size: 288 Bytes
6163604
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
import os
import numpy as np

def get_freer_gpu():
    '''
    Find which gpu is free
    '''
    os.system('nvidia-smi -q -d Memory |grep -A4 GPU|grep Free >tmp')
    memory_available = [int(x.split()[2]) for x in open('tmp', 'r').readlines()]
    return int(np.argmax(memory_available))