def time_render(filename: str) -> str:
# Run the render and time the operation
# We expect the full path for the file
command_to_run = '{} -b {} -f 10 -- --cycles-device CUDA'.format(
render_executable, filename)
cmd = subprocess.Popen(command_to_run, shell=True, stdout=subprocess.PIPE)
elapsed_time_str = '-1' # if you see this output, something bad happened
for line in cmd.stdout:
decoded_line = line.decode().strip()
if "Time: " in decoded_line and "(Saving: " in decoded_line:
start_index = decoded_line.find(":")
end_index = decoded_line.find("(")
# this is the line we want with the render time
elapsed_time_str = convert_to_seconds(
decoded_line[start_index+1:end_index].strip())
return elapsed_time_str
def get_peak_GPU_mem() -> dict:
# Monitor the memory usage on the GPU and
# record the peak
peak_mem = {}
command_to_run = 'nvidia-smi --query-gpu=gpu_bus_id,memory.used --format=csv -l 1'
cmd = subprocess.Popen(command_to_run, shell=True, stdout=subprocess.PIPE)
for line in cmd.stdout:
decoded_line = line.decode().strip()
# The output of this command will usually look like this:
# 00000000:2D:00.0, 101 MiB
Подробнее здесь: [url]https://stackoverflow.com/questions/79434771/launching-multiple-commands-in-parallel-and-parsing-their-outputs[/url]
У меня есть две функции, каждая из которых запускает команду, и мне нужно запустить оба параллельно: < /p> [code]def time_render(filename: str) -> str: # Run the render and time the operation # We expect the full path for the file command_to_run = '{} -b {} -f 10 -- --cycles-device CUDA'.format( render_executable, filename) cmd = subprocess.Popen(command_to_run, shell=True, stdout=subprocess.PIPE) elapsed_time_str = '-1' # if you see this output, something bad happened for line in cmd.stdout: decoded_line = line.decode().strip() if "Time: " in decoded_line and "(Saving: " in decoded_line: start_index = decoded_line.find(":") end_index = decoded_line.find("(")
# this is the line we want with the render time elapsed_time_str = convert_to_seconds( decoded_line[start_index+1:end_index].strip())
return elapsed_time_str
def get_peak_GPU_mem() -> dict: # Monitor the memory usage on the GPU and # record the peak peak_mem = {} command_to_run = 'nvidia-smi --query-gpu=gpu_bus_id,memory.used --format=csv -l 1' cmd = subprocess.Popen(command_to_run, shell=True, stdout=subprocess.PIPE) for line in cmd.stdout: decoded_line = line.decode().strip()
# The output of this command will usually look like this: # 00000000:2D:00.0, 101 MiB
У меня есть две функции, каждая из которых запускает команду, и мне нужно запустить оба параллельно:
def time_render(filename: str) -> str:
# Run the render and time the operation
# We expect the full path for the file
command_to_run = '{} -b {}...
У меня есть принтер TSC TE 210. Я создал виртуальный принтер на порту Redmon и установил на нем драйвер TSC. Я могу сгенерировать файл printfile.prn с использованием Redmon (перенаправление вывода на Python, который будет редактировать данные и...
У меня есть принтер TSC TE 210. Я создал виртуальный принтер на порту Redmon и установил на нем драйвер TSC. Я могу сгенерировать файл printfile.prn с использованием Redmon (перенаправление вывода на Python, который будет редактировать данные и...
У меня есть принтер TSC TE 210. Я создал виртуальный принтер на порту Redmon и установил на нем драйвер TSC. Я могу сгенерировать файл printfile.prn с использованием Redmon (перенаправление вывода на Python, который будет редактировать данные и...
У меня есть принтер TSC TE 210. Я создал виртуальный принтер на порту Redmon и установил на нем драйвер TSC. Я могу сгенерировать файл printfile.prn с использованием Redmon (перенаправление вывода на Python, который будет редактировать данные и...