-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·42 lines (30 loc) · 1.16 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import absolute_import, division, print_function, unicode_literals
import subprocess
import tensorflow as tf
import os
is_gpu_available = tf.test.is_gpu_available()
message = "GPU available: {}".format(is_gpu_available)
print(message)
try:
os.mkdir('run-result')
except OSError:
pass
with open('run-result/output.txt', 'w') as f:
f.write(message)
if is_gpu_available:
gpu_count = str(subprocess.check_output(["nvidia-smi", "--query-gpu=count", "--format=csv,noheader" ]), "utf-8")
gpu_name = str(subprocess.check_output(["nvidia-smi", "--query-gpu=name", "--format=csv,noheader" ]), "utf-8")
gpu_memory = str(subprocess.check_output(["nvidia-smi", "--query-gpu=memory.total", "--format=csv,noheader" ]), "utf-8")
message = "Test Summary"
print (message)
f.write(message)
message = "GPU count: {}".format(gpu_count)
print (message)
f.write(message)
message = "GPU name: {}".format(gpu_name)
print (message)
f.write(message)
message = "GPU memory: {}".format(gpu_memory)
print (message)
f.write(message)
print("DONE")