|
|
@@ -229,30 +229,6 @@ def main():
|
|
|
image_files = image_files[:20]
|
|
|
print(f"Test mode: processing only {len(image_files)} images")
|
|
|
|
|
|
- # 验证设备
|
|
|
- if args.device.startswith('gpu'):
|
|
|
- try:
|
|
|
- import paddle
|
|
|
- if not paddle.device.is_compiled_with_cuda():
|
|
|
- print("GPU requested but CUDA not available, falling back to CPU")
|
|
|
- args.device = "cpu"
|
|
|
- else:
|
|
|
- gpu_count = paddle.device.cuda.device_count()
|
|
|
- device_id = int(args.device.split(':')[1]) if ':' in args.device else 0
|
|
|
- if device_id >= gpu_count:
|
|
|
- print(f"GPU {device_id} not available (only {gpu_count} GPUs), falling back to GPU 0")
|
|
|
- args.device = "gpu:0"
|
|
|
-
|
|
|
- # 显示GPU信息
|
|
|
- if args.verbose:
|
|
|
- for i in range(gpu_count):
|
|
|
- props = paddle.device.cuda.get_device_properties(i)
|
|
|
- print(f"GPU {i}: {props.name} - {props.total_memory // 1024**3}GB")
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- print(f"Error checking GPU availability: {e}, falling back to CPU")
|
|
|
- args.device = "cpu"
|
|
|
-
|
|
|
print(f"Using device: {args.device}")
|
|
|
print(f"Batch size: {args.batch_size}")
|
|
|
|