Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions s2p/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,16 +644,18 @@ def main(user_cfg, start_from=0):
if cfg['max_processes_stereo_matching'] is not None:
nb_workers_stereo = cfg['max_processes_stereo_matching']
else:
nb_workers_stereo = nb_workers
nb_workers_stereo = max(1, int(nb_workers / 2.0))
try:

print(f'4) running stereo matching using {nb_workers_stereo} workers...')
parallel.launch_calls(stereo_matching, tiles_pairs, nb_workers_stereo,
timeout=timeout)
except subprocess.CalledProcessError as e:
print(f'ERROR: stereo matching failed. In case this is due too little RAM set '
f'"max_processes_stereo_matching" to a lower value (currently set to: {nb_workers_stereo}).')
raise e
except ValueError as e:
nb_workers_stereo /= 2.0
nb_workers_stereo = max(1, int(nb_workers_stereo))
print(f"Retrying stereo matching with {nb_workers_stereo} workers...")
parallel.launch_calls(stereo_matching, tiles_pairs, nb_workers_stereo,
timeout=timeout)

if start_from <= 5:
if n > 2:
Expand Down
9 changes: 9 additions & 0 deletions s2p/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Copyright (C) 2017, Carlo de Franchis <[email protected]>

import os
import time
import psutil
import sys
import traceback
import multiprocessing
Expand Down Expand Up @@ -97,6 +99,13 @@ def launch_calls(fun, list_of_args, nb_workers, *extra_args, tilewise=True,
else:
results.append(pool.apply_async(fun, args=args, callback=show_progress))

while any([not r.ready() for r in results]):
time.sleep(1)
if (psutil.virtual_memory().available * 100 / psutil.virtual_memory().total) < 5.0:
pool.terminate()
raise ValueError(f'RAM usage is too high using {nb_workers} workers, killing the process')


for r in results:
try:
outputs.append(r.get(timeout))
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def finalize_options(self):


requirements = ['numpy',
'psutil',
'scipy',
'rasterio[s3] @ https://github.com/rasterio/rasterio/archive/refs/tags/1.3.3.tar.gz',
'utm',
Expand Down