n_tasks = int(os.environ['SLURM_NPROCS'])
port = int(os.environ['SLURM_STEP_RESV_PORTS'].split('-')[0])
tf_hostlist = [('%s:%s' % (host, port)) for host in expand_hostlist(os.
    environ['SLURM_NODELIST'])]
Running TensorFlow on a Slurm Cluster?