import subprocess def test(): # proc = subprocess.Popen(['env'], stdout=subprocess.PIPE) proc = subprocess.Popen(['nvidia-smi'], stdout=subprocess.PIPE) # proc = subprocess.Popen(['nvidia-smi', '-q', '-i', '0'], stdout=subprocess.PIPE) # proc = subprocess.Popen(['ls', '/usr/bin/'], stdout=subprocess.PIPE) # proc = subprocess.Popen('ls', stdout=subprocess.PIPE) return proc.stdout.read()