소스 검색

refactor(zhch): 移除 GPU 设备检查代码

- 删除了 GPU 设备检查和回退到 CPU 的逻辑
- 移除了 GPU 信息显示的相关代码
- 简化了设备配置流程,直接使用 args.device 参数
zhch158_admin 3 달 전
부모
커밋
b11b479a57
1개의 변경된 파일0개의 추가작업 그리고 24개의 파일을 삭제
  1. 0 24
      zhch/ppstructurev3_single_process.py

+ 0 - 24
zhch/ppstructurev3_single_process.py

@@ -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}")