通过命令行控制MPS
作者:互联网
重要参考文献
https://docs.python.org/3/library/os.html#os.popen
https://janakiev.com/blog/python-shell-commands/
这里需要详细对比一下链接2中对于三种通讯方式的分析
import os
PID = 43926
stream = os.popen("sudo su root", mode='w', buffering=-1)
stream.write("sudo nvidia-cuda-mps-control \n")
stream.write("set_active_thread_percentage "+str(PID)+" 50\n")
#result = stream.write("nvidia-cuda-mps-control \n")
#stream.write("quit\n")
#stream.write("stream.write(sudo nvidia-cuda-mps-control )
stream.close()
标签:control,控制,stream,sudo,write,MPS,命令行,os,cuda 来源: https://blog.csdn.net/cleanarea/article/details/115356289