Add --gpu flag to select specific GPU(s) for processing
This commit is contained in:
@ -107,6 +107,16 @@ Exemples:
|
||||
default=1,
|
||||
help="Nombre de workers pour traitement parallèle (défaut: 1)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-g", "--gpu",
|
||||
nargs="?",
|
||||
const="all",
|
||||
default=None,
|
||||
metavar="LISTE",
|
||||
help="Sélectionner le(s) GPU(s) à utiliser : un index (ex: -g 0), "
|
||||
"une liste (ex: -g 0,2), ou 'all' pour tous (ex: -g). "
|
||||
"Sans -g : GPU auto (le premier si disponible)."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f", "--force",
|
||||
action="store_true",
|
||||
@ -190,6 +200,21 @@ Exemples:
|
||||
logger.info("Pipeline LiDAR Archéologique")
|
||||
logger.info("=" * 60)
|
||||
|
||||
# Parse --gpu into a list of GPU IDs
|
||||
gpu_ids = None
|
||||
gpu_arg = args.gpu
|
||||
if gpu_arg is not None:
|
||||
if gpu_arg == 'all':
|
||||
gpu_ids = None # Don't restrict — use all GPUs
|
||||
else:
|
||||
try:
|
||||
gpu_ids = [int(g.strip()) for g in gpu_arg.split(',')]
|
||||
except ValueError:
|
||||
parser.error(f"GPU invalide: {gpu_arg!r}. Utilisez un index, une liste (0,2) ou 'all'.")
|
||||
if gpu_ids is not None:
|
||||
from .gpu import restrict_gpus
|
||||
restrict_gpus(gpu_ids)
|
||||
|
||||
# Kill orphan PDAL processes on interrupt or termination
|
||||
signal.signal(signal.SIGINT, _kill_orphan_pdal)
|
||||
signal.signal(signal.SIGTERM, _kill_orphan_pdal)
|
||||
@ -220,6 +245,7 @@ Exemples:
|
||||
only_viz=only_viz,
|
||||
skip_viz=skip_viz,
|
||||
output_format=args.format,
|
||||
gpu_ids=gpu_ids,
|
||||
)
|
||||
|
||||
# If --file is specified, process only matching files
|
||||
|
||||
Reference in New Issue
Block a user