GenCast

Model Overview

GenCast is a probabilistic global weather forecasting model developed by Google DeepMind. Its paper appeared as the cover article of the leading scientific journal Nature on December 4, 2024.

Paper: GenCast: Diffusion-Based Ensemble Forecasting for Medium-Range Weather

https://arxiv.org/abs/2312.15796

Model Description

GenCast is an ensemble forecasting model built with graph neural networks and diffusion models. Across a comprehensive set of evaluations, it outperformed ENS, the European Centre for Medium-Range Weather Forecasts' (ECMWF) leading ensemble forecasting system.

Use Cases

Use Case Description
Weather forecasting training Train the model on ERA5 data in HDF5 format that conforms to the GenCast data protocol.
Quick local validation Use synthetic data to validate data loading, model training and inference, and visualization of inference results.
ModelScope/OneCode execution Download the standalone model package, install its dependencies, and run the included scripts directly.
Multi-GPU training Use JAX pmap for data-parallel training across multiple GPUs or accelerators on a single host.

Usage

1. Using OneCode

Use the OneCode online environment for an intelligent, one-click AI4S development experience:

Try one-click AI4S development with OneCode

2. Manual Setup

Hardware Requirements

  • A GPU or DCU is recommended.
  • A CPU can be used for import checks and connectivity validation with a minimal configuration, but full training and inference will be slow.
  • DCU users must install DTK in advance. DTK 25.04.2 or later is recommended; alternatively, use the OneScience-recommended version compatible with your cluster.

Download the Model Package

hf download OneScience-Group/GenCast --local-dir ./GenCast
cd GenCast

Set Up the Runtime Environment

DCU Environment

# Activate DTK and conda first.
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# Installation with uv is also supported.
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU Environment

# Activate conda first.
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# Installation with uv is also supported.
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

Training Data

The OneScience community provides ERA5 data for training. Because of file-size constraints, the repository currently contains a self-contained data slice. Download the data with the following command and ensure that the data path in conf/config.yaml is configured correctly:

hf download --repo-type dataset OneScience-Group/ERA5 --local-dir ./data

Training

Single GPU:

# If real data is unavailable, first run `python scripts/fake_data.py` to generate synthetic data.
python scripts/train.py

Multiple GPUs:

CUDA_VISIBLE_DEVICES=0,1 python scripts/train.py --config conf/config.yaml --parallel-mode pmap --num-devices 2 --global-batch-size 2
# CUDA_VISIBLE_DEVICES specifies the GPU indices to expose.
# --num-devices specifies the number of GPUs to use.
# --global-batch-size specifies the batch size and must be divisible by the number of GPUs.

After training, the weights are saved to data/checkpoints/model_bak.npz.

Pre-trained Weights

This repository will provide weights trained on ERA5 reanalysis data in the weights/ directory. The weight files are being prepared and will be uploaded soon.

Inference

By default, inference loads data/checkpoints/model_bak.npz:

python scripts/inference.py

Evaluation and Visualization

python scripts/result.py

Official OneScience Resources

Citation and License

  • This repository is a reproduction of the original GenCast paper.

中文说明

模型概述

GenCast 是由 Google DeepMind 开发的全球概率天气预报(weather forecasting)模型。其论文于 2024 年十二月 4 日作为顶尖科学期刊 Nature 的封面文章发表。

论文《GenCast:基于扩散模型的中期天气集合预报(ensemble forecasting)》

https://arxiv.org/abs/2312.15796

模型描述

GenCast 是基于图神经网络和扩散模型构建的集合预报模型。在一系列综合评估中,它的表现优于欧洲中期天气预报中心(ECMWF)的领先集合预报系统 ENS。

使用场景

使用场景 说明
天气预报训练 使用符合 GenCast 数据协议的 HDF5 格式 ERA5 数据训练模型。
本地快速验证 使用合成数据验证数据加载、模型训练和推理(inference)以及推理结果可视化。
ModelScope/OneCode 运行 下载独立模型包,安装依赖后直接运行随附的脚本。
多 GPU 训练 使用 JAX pmap 在单台主机上的多个 GPU 或加速器上进行数据并行训练。

使用方法

1. 使用 OneCode

通过 OneCode 在线环境体验智能一键 AI4S 开发。

使用 OneCode 体验一键 AI4S 开发

2. 手动配置

硬件要求

  • 建议使用 GPU 或 DCU。
  • 可使用 CPU 在最小配置下检查导入和验证连通性,完整训练和推理的速度会较慢。
  • DCU 用户必须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,也可使用 OneScience 推荐的与所在集群兼容的版本。

下载模型包

hf download OneScience-Group/GenCast --local-dir ./GenCast
cd GenCast

配置运行环境

DCU 环境

# Activate DTK and conda first.
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# Installation with uv is also supported.
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU 环境

# Activate conda first.
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# Installation with uv is also supported.
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

训练数据

OneScience 社区提供用于训练的 ERA5 数据。受文件大小限制,仓库目前包含一个自包含的数据切片。请使用以下命令下载数据,并确保 conf/config.yaml 中的数据路径配置正确。

hf download --repo-type dataset OneScience-Group/ERA5 --local-dir ./data

训练

单 GPU

# If real data is unavailable, first run `python scripts/fake_data.py` to generate synthetic data.
python scripts/train.py

多 GPU

CUDA_VISIBLE_DEVICES=0,1 python scripts/train.py --config conf/config.yaml --parallel-mode pmap --num-devices 2 --global-batch-size 2
# CUDA_VISIBLE_DEVICES specifies the GPU indices to expose.
# --num-devices specifies the number of GPUs to use.
# --global-batch-size specifies the batch size and must be divisible by the number of GPUs.

训练完成后,权重保存到 data/checkpoints/model_bak.npz。

预训练权重

本仓库将在 weights/ 目录中提供使用 ERA5 再分析(reanalysis)数据训练得到的权重。权重文件正在准备中,即将上传。

推理

默认情况下,推理加载 data/checkpoints/model_bak.npz。

python scripts/inference.py

评估与可视化

python scripts/result.py

OneScience 官方资源

引用与许可证

  • 本仓库是对 GenCast 原始论文的复现。
Downloads last month
20
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for OneScience-Group/GenCast