Skip to content

Commit ce8f5ff

Browse files
committed
Add a first check for gpus available
1 parent 78cec35 commit ce8f5ff

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Configuration/PyReleaseValidation/python/MatrixRunner.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os, sys, time
2+
import subprocess
23

34
from collections import Counter
45

@@ -16,9 +17,23 @@ def __init__(self, wfIn=None, nThrMax=4, nThreads=1, gpu=False):
1617
self.threadList = []
1718
self.maxThreads = nThrMax
1819
self.nThreads = nThreads
19-
self.gpu = gpu
20-
21-
if self.gpu:
20+
self.gpus = ()
21+
22+
if gpu:
23+
print("> Running with --gpu option. Checking the GPUs available.")
24+
cuda = subprocess.check_output("cudaComputeCapabilities", shell=True, executable="/bin/bash").decode('utf8')
25+
# Building on top of the {cuda|rocm}ComputeCapabilities
26+
# output in case of no {NVIDIA|AMD} GPU:
27+
# 'no XXX-capable device is detecte'
28+
if "capable device is detected" in cuda:
29+
cuda = 0
30+
else:
31+
print(cuda.split("\n"))
32+
rocm = subprocess.check_output("rocmComputeCapabilities", shell=True, executable="/bin/bash").decode('utf8')
33+
if "capable device is detected" in rocm:
34+
rocm = 0
35+
else:
36+
print(cuda.split("\n"))
2237
print("Checks for GPU")
2338
pass
2439

0 commit comments

Comments
 (0)