|
@@ -42,11 +42,6 @@ def worker(pipeline_name_or_config_path: str,
|
|
|
"""
|
|
"""
|
|
|
try:
|
|
try:
|
|
|
# 创建pipeline实例
|
|
# 创建pipeline实例
|
|
|
- from dotenv import load_dotenv
|
|
|
|
|
- load_dotenv(override=True)
|
|
|
|
|
- print(f"CUDA_VISIBLE_DEVICES: {os.environ.get('CUDA_VISIBLE_DEVICES')}")
|
|
|
|
|
- import paddle
|
|
|
|
|
- paddle.set_device(device)
|
|
|
|
|
pipeline = create_pipeline(pipeline_name_or_config_path, device=device)
|
|
pipeline = create_pipeline(pipeline_name_or_config_path, device=device)
|
|
|
print(f"Worker {worker_id} initialized with device {device}")
|
|
print(f"Worker {worker_id} initialized with device {device}")
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -211,14 +206,6 @@ def parallel_process_with_official_approach(image_paths: List[str],
|
|
|
print(f" Batch size: {batch_size}")
|
|
print(f" Batch size: {batch_size}")
|
|
|
print(f" Total images: {len(image_paths)}")
|
|
print(f" Total images: {len(image_paths)}")
|
|
|
|
|
|
|
|
- # 在主进程中初始化paddle,防止子进程CUDA初始化冲突
|
|
|
|
|
- try:
|
|
|
|
|
- import paddle
|
|
|
|
|
- # 只在主进程中设置一个默认设备
|
|
|
|
|
- paddle.set_device("cpu") # 主进程使用CPU
|
|
|
|
|
- except Exception as e:
|
|
|
|
|
- print(f"Warning: Failed to initialize paddle in main process: {e}")
|
|
|
|
|
-
|
|
|
|
|
# 使用Manager创建队列
|
|
# 使用Manager创建队列
|
|
|
with Manager() as manager:
|
|
with Manager() as manager:
|
|
|
task_queue = manager.Queue()
|
|
task_queue = manager.Queue()
|