Skip to content

Commit 67683da

Browse files
committed
Replace malformed nvidia-smi XML
1 parent 20f01e0 commit 67683da

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cwltool/cuda.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ def cuda_version_and_device_count() -> Tuple[str, int]:
1515
except Exception as e:
1616
_logger.warning("Error checking CUDA version with nvidia-smi: %s", e)
1717
return ("", 0)
18-
dm = xml.dom.minidom.parseString(out) # nosec
18+
19+
# Apparently nvidia-smi is not safe to call concurrently.
20+
# With --parallel, sometimes the returned XML will contain
21+
# <process_name>\xff...\xff</process_name>
22+
# and xml.dom.minidom.parseString will raise
23+
# "xml.parsers.expat.ExpatError: not well-formed (invalid token)"
24+
out_no_xff = out.replace(b'\xff', b'')
25+
dm = xml.dom.minidom.parseString(out_no_xff) # nosec
1926

2027
ag = dm.getElementsByTagName("attached_gpus")
2128
if len(ag) < 1 or ag[0].firstChild is None:

0 commit comments

Comments
 (0)