OneScience-Group/GraphCast
014
1---2frameworks: PyTorch3language:4- en5- zh6license: apache-2.07tags:8- OneScience9- Earth Science10- Weather Forecast11- Short-to-Medium-Range Weather Forecast12- ERA513tasks: []14datasets:15 - OneScience/ERA516---17<p align="center">18 <strong>19 <span style="font-size: 30px;">GraphCast</span>20 </strong>21</p>22 23# Model Introduction24 25GraphCast is a global medium-range weather forecast model developed by the Google DeepMind team, with its core paper published in the top-tier international journal *Science*.26 27Paper: GraphCast: Learning skillful medium-range global weather forecasting28 29https://arxiv.org/abs/2212.1279430 31# Model Description32 33GraphCast is a global medium-range weather forecast model built on a Graph Neural Network (GNN). It is trained on the ERA5 global atmospheric reanalysis dataset (1979–2017) provided by ECMWF.34 35# Use Cases36 37| Scenario | Description |38| :---: | :--- |39| Global Weather Forecast Research | Train a GraphCast-style GNN forecast model using annual ERA5 HDF5 data. |40| Local Quick Validation | Use synthetic data to verify data loading, auxiliary file generation, training entry points, and result scripts. |41| ModelScope / OneCode Execution | Download as a standalone model package, install dependencies, and run scripts directly. |42| Multi-GPU Training | Launch multi-process training via `torchrun`. |43 44# Usage Guide45 46## 1. OneCode Usage47 48Experience intelligent one-click AI4S programming through the OneCode online environment:49 50[Click to Experience Intelligent One-Click AI4S Programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)51 52## 2. Manual Installation and Usage53 54**Hardware Requirements**55 56- A GPU or DCU is recommended.57- CPU can be used for import and small-scale connectivity verification; full training and inference will be slow.58- DCU users must install DTK in advance. DTK 25.04.2 or above, or the OneScience recommended version matching your cluster, is recommended.59 60### Download the Model Package61 62```bash63hf download OneScience-Group/GraphCast --local-dir ./GraphCast64cd GraphCast65```66 67### Install the Runtime Environment68 69**DCU Environment**70 71```bash72# Please activate DTK and CONDA first73conda create -n onescience311 python=3.11 -y74conda activate onescience31175# uv installation is supported76pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai77```78 79**GPU Environment**80```bash81# Please activate CONDA first82conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=1283conda activate onescience31184# uv installation is supported85pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai86```87 88### Training Data Introduction89 90The OneScience community provides ERA5 data for training (due to file size limits, the current repository contains a slice of the full dataset). Users can download it with the command below and confirm that the data path in `conf/config.yaml` is set correctly:91 92```bash93hf download --repo-type dataset OneScience-Group/ERA5 --local-dir ./data94```95 96### Generate Auxiliary Files97 98```bash99python scripts/get_data_json.py100python scripts/compute_time_diff_std.py101```102 103Generated files:104 105- `data.json`106- `time_diff_std.npy`107 108### Training109 110Single GPU:111 112```bash113python scripts/train.py114```115 116Multi-GPU:117 118```bash119torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py120```121 122Training outputs:123 124```text125data/checkpoints/model_bak.pth126data/checkpoints/trloss.npy127```128 129### Training Weights130 131This repository provides weights trained on ERA5 data from 1979 to 2017 in the `weights/` folder. The weight files will be uploaded soon and are expected to be available in the near future.132 133### Fine-tuning134 135Before fine-tuning, you must first complete training and generate `data/checkpoints/model_bak.pth`.136 137```bash138python scripts/finetune.py139```140 141Fine-tuning outputs:142 143```text144data/checkpoints/model_finetune_bak.pth145data/checkpoints/ft_trloss.npy146```147 148### Inference149 150Inference reads `data/checkpoints/model_finetune_bak.pth` by default:151 152```bash153python scripts/inference.py154```155 156Prediction results are output to:157 158```text159result/output/160```161 162### Evaluation and Visualization163 164```bash165python scripts/result.py166```167 168Output contents include:169 170- `result/rmse.npy`171- `result/acc.npy`172- `result/loss.png`173- Forecast comparison plots for specified dates and variables174 175# OneScience Official Information176 177| Platform | OneScience Main Repository | Skills Repository |178| --- | --- | --- |179| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |180| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |181 182# Citation & License183 184- Apache License 2.0. The code is open source, permitting both commercial and non-commercial use.185- The weights are permitted for non-commercial use only.186 