如何使用Snakemake进行内存管理?

How to use Snakemake for memory management?

我试图强制 Snakemake 按顺序执行 运行 规则(有很多作业)以避免内存冲突。


rule run_eval_all:
    input:
        expand("config["out_model"] + "{iLogit}.rds", iLogit = MODELS)

rule eval_model:
    input:
        script = config["src_est"] + "evals/script.R",
        model = config["out_model"] + "{iLogit}.rds",
    output:
        "out/{iLogit}.rds"

    threads: 5
    resources:
        mem_mb = 100000
    shell:
        "{runR} {input.script} "
        "--out {output}"

而我 运行 规则 snakemake --cores all --resources mem_mb=100000 run_eval_all。但我不断收到如下错误:

x86_64-conda-linux-gnu % snakemake --resources mem_mb=100000 run_eval_all
Traceback (most recent call last):
  File "/local/home/zhakaida/mambaforge/envs/r_snake/bin/snakemake", line 10, in <module>
    sys.exit(main())
  File "/local/home/zhakaida/mambaforge/envs/r_snake/lib/python3.9/site-packages/snakemake/__init__.py", line 2401, in main
    resources = parse_resources(args.resources)
  File "/local/home/zhakaida/mambaforge/envs/r_snake/lib/python3.9/site-packages/snakemake/resources.py", line 85, in parse_resources
    for res, val in resources_args.items():
AttributeError: 'list' object has no attribute 'items'

如果我 运行 snakemake --cores all run_eval_all,它可以工作,但工作 运行 是并行的(如预期的那样),有时会导致内存过度使用和崩溃。我应该如何正确地为Snakemake申请内存?

该错误是由于在 Snakemake 6.5.1 中解析 --resources 参数的一个已知问题,https://github.com/snakemake/snakemake/issues/1069

更新到snakemake 6.5.3或更高版本,看看你的问题是否还存在。