-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from liyancn/master
add example of submitting GPU job
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from pythonlsf import lsf | ||
|
||
|
||
def run_job(command): | ||
""" | ||
Run a job... | ||
""" | ||
submitreq = lsf.submit() | ||
submitreq.command = command | ||
#submitreq.options = 0 | ||
submitreq.options2 = 0 | ||
|
||
limits = [] | ||
for i in range(0, lsf.LSF_RLIM_NLIMITS): | ||
limits.append(lsf.DEFAULT_RLIMIT) | ||
|
||
submitreq.rLimits = limits | ||
|
||
submitreq.beginTime = 0 | ||
submitreq.termTime = 0 | ||
submitreq.numProcessors = 1 | ||
submitreq.maxNumProcessors = 1 | ||
|
||
# below 2 lines section is for using -R rusage to request GPU | ||
#submitreq.resReq = "rusage[ngpus_physical=2:gmodel=K80#12G:nvlink=yes]" | ||
#submitreq.options = lsf.SUB_RES_REQ | ||
|
||
# below section is for using -gpu to request GPU | ||
submit_ext = lsf.submit_ext() | ||
submitreq.options2 = lsf.SUB2_MODIFY_PEND_JOB | ||
submitreq.options4 = lsf.SUB4_GPU_REQ | ||
gpuOpt = {} | ||
gpuOpt[lsf.JDATA_EXT_GPU_NUM] = "2" | ||
gpuOpt[lsf.JDATA_EXT_GPU_MODE] = "3" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_MPS_ENABLE] = "-1" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_JOB_EXCLUSIVE] = "-1" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_MODEL] = "" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_MEM] = "" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_TILE] = "" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_AFFBIND] = "-1" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_BLOCK] = "-1" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_GPACK] = "-1" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_GVENDOR] = "-1" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_RSRC_TYPE] = "0" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_GI_SLICE] = "-1" | ||
#gpuOpt[lsf.JDATA_EXT_GPU_CI_SLICE] = "-1" | ||
|
||
submit_ext.keys = lsf.new_intArray(len(gpuOpt)) | ||
submit_ext.values = lsf.new_stringArray(len(gpuOpt)) | ||
for i in range(len(gpuOpt)): | ||
lsf.intArray_setitem(submit_ext.keys, i, gpuOpt.keys()[i]) | ||
lsf.stringArray_setitem(submit_ext.values, i, gpuOpt.values()[i]) | ||
submit_ext.num = len(gpuOpt) | ||
submitreq.submitExt = submit_ext | ||
print(submitreq.submitExt.num) | ||
|
||
# submit the job request | ||
submitreply = lsf.submitReply() | ||
|
||
if lsf.lsb_init("test") > 0: | ||
exit(1) | ||
|
||
job_id = lsf.lsb_submit(submitreq, submitreply) | ||
return job_id | ||
|
||
|
||
if __name__ == '__main__': | ||
print("LSF Clustername is :", lsf.ls_getclustername()) | ||
print(run_job("/bin/sleep 10")) |