PyPSA-eur:由于使用 VS code 的 Ubuntu WSL 中的内存使用率过高,Snakemake 管道被终止

问题描述 投票:0回答:2

对于我的硕士论文,我想进一步开发波罗的海地区的 PyPSA-Eur 能源系统模型。在进行开发之前,我必须成功运行模型。我通过从 Github 克隆代码并使用 Visual Studio Code 在 Ubuntu WSL 环境中运行代码来运行 PyPSA-Euro 模型,以解决我之前遇到的权限错误。我没有对现有代码进行任何更改,而是根据environment.yaml 文件更新了所有包。 Github 上的 PyPSA-Eur 存储库:

https://github.com/PyPSA/pypsa-eur

我不断遇到的错误是在终端中运行 Snakemake --cores all 时规则 build_renewable_profiles 中的错误。该错误消息表明在 Snakemake 管道中运行 build_renewable_profiles 规则的进程由于内存使用率过高而被终止。这可能是由于工作进程超出了其内存限制。

我尝试通过在 Snakefile 中添加脚本来增加 Dask Worker 的内存限制。另外,我尝试通过在WSL环境的用户目录中添加.wslconfig文件来增加WSL环境的内存限制,指定8GB内存。然而,这两种方法都没有解决错误。我的系统总内存为 16GB。

我恳请有关如何解决此类错误的帮助,如提供的图像中所示。解决这个错误使我能够成功运行 PyPSA 模型,并继续为我的硕士论文开发 PyPSA-eur 能源系统。

非常感谢, 斯蒂恩

运行snakemake后完整终端消息的第一张图片:
First image of the full terminal message after running snakemake

运行snakemake后完整终端消息的第二张图片,包括错误消息:
Second image of the full terminal message after running snakemake, including the error message

运行后包含错误消息的终端部分

snakemake --cores all
:

INFO:__main__:Calculate landuse availabilities...
INFO:__main__:Completed availability calculation (95.49s)
INFO:atlite.convert:Convert and aggregate 'pv'.
2023-12-27 14:44:34,179 - distributed.worker.memory - WARNING - Unmanaged memory use is high. This may indicate a memory leak or the memory may not be released to the OS; see https://distributed.dask.org/en/latest/worker-memory.html#memory-not-released-back-to-the-os for more information. -- Unmanaged memory: 1.38 GiB -- Worker memory limit: 1.91 GiB
2023-12-27 14:44:36,119 - distributed.worker.memory - WARNING - Unmanaged memory use is high. This may indicate a memory leak or the memory may not be released to the OS; see https://distributed.dask.org/en/latest/worker-memory.html#memory-not-released-back-to-the-os for more information. -- Unmanaged memory: 1.36 GiB -- Worker memory limit: 1.91 GiB
2023-12-27 14:44:37,196 - distributed.worker.memory - WARNING - Worker is at 81% memory usage. Pausing worker.  Process memory: 1.55 GiB -- Worker memory limit: 1.91 GiB
[Wed Dec 27 14:44:38 2023]
Error in rule build_renewable_profiles:
    jobid: 10
    input: resources/networks/base.nc, data/bundle/corine/g250_clc06_V18_5.tif, resources/natura.tiff, resources/country_shapes.geojson, resources/offshore_shapes.geojson, resources/regions_onshore.geojson, cutouts/europe-2013-sarah.nc
    output: resources/profile_solar.nc
    log: logs/build_renewable_profile_solar.log (check log file(s) for error details)
    conda-env: /home/cfl/pypsa-balticsea/.snakemake/conda/a193a967e4b3183c6023115ed840b879_

RuleException:
CalledProcessError in file /home/cfl/pypsa-balticsea/rules/build_electricity.smk, line 309:
Command 'set -euo pipefail;  /home/cfl/miniconda3/envs/pypsa-eur/bin/python3.11 /home/cfl/pypsa-balticsea/.snakemake/scripts/tmpwdpwcq1a.build_renewable_profiles.py' died with <Signals.SIGKILL: 9>.
  File "/home/cfl/pypsa-balticsea/rules/build_electricity.smk", line 309, in __rule_build_renewable_profiles
  File "/home/cfl/miniconda3/envs/pypsa-eur/lib/python3.11/concurrent/futures/thread.py", line 58, in run
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
/home/cfl/miniconda3/envs/pypsa-eur/lib/python3.11/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 24 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '
Complete log: .snakemake/log/2023-12-27T144217.073372.snakemake.log
python memory terminal snakemake pypsa
2个回答
0
投票

规则

build_renewable_profiles
可能相当耗费资源,并且可能会并行运行多次(对于太阳能、陆上风电、海上风电等)

您可以重试:

snakemake -j1

这将一次只执行一个规则,最大限度地减少内存消耗。


0
投票

Fabian 的方法将使用大量内存来限制规则,但也会消除任何并行性。您有一些更好的选择:

  • 将自定义资源添加到大内存规则中,以限制一次仅运行一个实例。无论其他系统属性如何(例如,如果您移动到另一台计算机或使用 slurm),这都会生效。
rule big_mem:
    resources:
        lots_of_memory=1

snakemake --resources lots_of_memory=1
调用。这将只允许该规则的一个实例运行,但其他作业仍可以同时运行。如果其他作业使用大量内存,这仍然可能导致崩溃。

  • 将违规规则的核心数量设置为一个很大的数字,例如100. 这将限制您的计算机仅运行大内存规则的一个实例,但一旦完成,将允许运行多个其他作业。快速破解,但不能很好地转化为集群。

  • 为每个规则分配

    mem_mb
    用法,并在您的系统约束下执行snakemake,
    snakemake --resources mem_mb=16000
    。 Snakemake 会负责会计,但不会执行限制。如果你说一条规则使用10GB但实际上使用12GB,它不会被snakemake杀死。这种方法比较耗时,并且可能仍然存在问题,但如果需要,可以让您轻松过渡到集群/云。

© www.soinside.com 2019 - 2024. All rights reserved.