ddp.dd = -1条件始终为ture zenme 处理
时间: 2024-03-29 16:40:44 浏览: 13
根据你提供的信息,我无法确定 `ddp.dd = -1` 条件为何会始终为 `true`,因为我不知道 `ddp` 对象的具体定义和使用方式。
然而,有可能是因为 `ddp` 对象中的 `dd` 属性被设置为 `-1`,并且在程序的其他地方没有被正确地修改,导致条件一直为真。另外,也有可能是程序中有其他的逻辑错误导致了这个问题的出现。
如果你能提供更多的程序细节和上下文信息,我可能能够更准确地回答你的问题。
相关问题
ddp = nd > 1 or (nd == 0 and torch.cuda.device_count() > 1) if ddp: port += 1 cmd = f'python -m torch.distributed.launch --nproc_per_node {nd} --master_port {port} train.py --resume {last}' else: cmd = f'python train.py --resume {last}'
这是一个关于使用 PyTorch 分布式训练的代码段,其中 nd 表示设备数量,ddp 表示是否使用分布式训练。如果 nd 大于 1 或者 nd 等于 0 且 CUDA 设备数量大于 1,则使用分布式训练,否则使用单设备训练。如果使用分布式训练,则指定端口号为 1,使用 torch.distributed.launch 命令启动训练,同时从上一次训练的检查点继续训练;如果使用单设备训练,则直接使用 train.py 脚本从上一次训练的检查点继续训练。
优化SQL select round( ohbmc.after_actual_amount/zz,0) cost_moneyi ,count(distinct case when ddp.orig_plan_rid = -1 then null else ddp.orig_plan_rid end) AS orig_num ,array_agg (dlt.state) AS loading_state ,count(DISTINCT CASE WHEN ddp.sale_planid = -1 THEN NULL ELSE ddp.sale_planid END) AS saleid_num--销地已计划数量 ,array_agg(dto.state) AS saletransport_state from ( SELECT id AS origin_planid , unnest(cabinet_rule_id) cabinet_rule_id -- 判断 next_plan_id 本身是空和 next_plan_id 为 {} ,unnest(case when (next_plan_id is null or next_plan_id[1] is null) then ARRAY[-1]::integer[] else next_plan_id end) as sale_planid --销地计划 , case when dp.plan_receiver_id is null then -1 else dp.plan_receiver_id end orig_plan_rid --产地计划 FROM ods.ods_durian_delivery_plan as dp left join ods.ods_hl_commodity_category as hcc on hcc.category_id = dp.category_id WHERE dp.type = 'ORIGIN' AND dp.deleted = 99 AND dp.tenant_id = 1 and cabinet_rule_id='{8}'or cabinet_rule_id='{9}'or cabinet_rule_id='{10000005}'---取白心火龙果 AND hcc.category_name = '火龙果') as ddp LEFT JOIN ods.ods_durian_loading_task AS dlt ON dlt.plan_id = ddp.origin_planid and dlt.plan_type='ORIGIN' AND dlt.deleted = 99 LEFT JOIN ods.ods_durian_transport_order AS dto ON dto.plan_id = ddp.sale_planid AND dto.deleted = 99 LEFT JOIN ods.ods_durian_receipt_task AS drt ON drt.plan_id = ddp.sale_planid AND drt.deleted = 99 LEFT JOIN ods.ods_durian_transport_order AS dto1 ON dto1.plan_id = ddp.sale_planid AND dto1.sort_no = 1 AND dto1.deleted = 99 left join (select odlsi.plan_id,sum(odlsi.quantity) zz from ods.ods_durian_loading_sku_item odlsi group by 1) odlsi on odlsi.plan_id=dlt.plan_id left join (select *, unnest(case when ( odbr.bill_main_id is null or odbr.bill_main_id is null) then ARRAY[-1]::integer[] else odbr.bill_main_id end) bill_main_id_r from ods.ods_durian_bill_rel odbr) odbr on odbr.data_id= dlt.plan_id and odbr.data_type='ORIGIN_FEE' left join ods.ods_hl_bill_main_currency ohbmc on ohbmc.bill_main_id=odbr.bill_main_id_r and ohbmc.deleted=99 group by 1;
这个SQL查询语句比较复杂,可以考虑以下几种优化方式:
1. 使用JOIN语句代替子查询:可以把子查询转换成JOIN语句,这样可以提高查询的效率。
2. 合理使用索引:根据实际情况,选择合适的索引可以大大提升查询效率。可以对WHERE子句中的条件表达式所涉及的列添加索引。
3. 减少DISTINCT关键字的使用:DISTINCT关键字会增加查询的开销,如果不必要,可以考虑去掉。
4. 减少聚合函数的使用:聚合函数是一种开销较大的操作,如果可以不用聚合函数,可以考虑去掉。
5. 优化WHERE子句中的条件表达式:可以优化WHERE子句中的条件表达式,尽量使用简单的条件表达式,减少复杂的逻辑判断。