Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

verify_gpu.py 872 B

You have to be logged in to leave a comment. Sign In
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
  1. import tensorflow as tf
  2. from pprint import pprint
  3. from tensorflow.python.client import device_lib
  4. def run():
  5. print('TF Version: ', tf.__version__)
  6. print('------Devices------')
  7. devices_detail = device_lib.list_local_devices()
  8. print(devices_detail)
  9. print('--------------------------------')
  10. device_list = tf.config.experimental.list_physical_devices('GPU')
  11. gpu_count = len(device_list)
  12. has_gpu = gpu_count > 0
  13. print("Num GPUs Available: ", gpu_count)
  14. print('Has gpu: ', has_gpu)
  15. pprint(device_list)
  16. return {
  17. 'has_gpu' : has_gpu,
  18. 'gpu_count' : gpu_count,
  19. 'devices' : [{
  20. 'name' : device.name,
  21. 'device_type' : device.device_type,
  22. 'physical_device_desc' : device.physical_device_desc
  23. } for device in devices_detail],
  24. }
  25. if __name__ == "__main__":
  26. run()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...