In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "GPU queuing script how to achieve idle trigger python script", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "GPU queuing script how to achieve idle trigger python script" this article.
Create a script first:
Vim narrow_setup.py
The sentence cmd = 'python xxx.py' sets the python script you want to run
# author: muzhan# contact: levio.pku@gmail.comimport osimport sysimport time cmd = 'python ~ / hehe.py' def gpu_info (): gpu_status = os.popen (' nvidia-smi | grep%'). Read (). Split (') gpu_memory = int (gpu_status [2] .split ('/') [0] .split ('M') [0] .strip () gpu_power = int (gpu_status [1] .split ( '') [- 1] .split ('/') [0] .split ('W') [0] .strip () return gpu_power Gpu_memory def narrow_setup (interval=2): gpu_power, gpu_memory = gpu_info () I = 0 while gpu_memory > 1000 or gpu_power > 20: # set waiting condition gpu_power Gpu_memory = gpu_info () I = I% 5 symbol = 'monitoring:' >'* I +'>'* I +'* (10-I-1) +'| 'gpu_power_str =' gpu power:%d W |'% gpu_power gpu_memory_str = 'gpu memory:%d MiB |'% gpu_memory sys.stdout.write ('\ r' + gpu_memory_str +) '+ gpu_power_str +''+ symbol) sys.stdout.flush () time.sleep (interval) I + = 1 print ('\ n' + cmd) os.system (cmd) if _ _ name__ = ='_ main__': narrow_setup ()
Run the script directly:
Python narrow_setup.py
You can listen to the information in nvidia-smi and wait for an opportunity to trigger the python script.
The running results are as follows:
Waiting for an opportunity. If the gpu video memory and power consumption are below a certain value, the python script will be triggered.
The above is all the content of the article "how GPU queuing script implements idle trigger python script". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.