U-RNN vs. hydrodynamic solver β 100-year return-period rainfall event, location1. U-RNN delivers >100Γ faster inference with high spatial accuracy at 2 m / 1 min resolution.
Β Quickest path β run the full pipeline in your browser in < 2 min. No GPU, no data download, no local setup.
π Prefer a cloud GPU for full-resolution training? Rent a single RTX 4090 on AutoDL for ~Β₯2/hour. A complete step-by-step guide using the browser-based JupyterLab is in Section 11 β Cloud GPU: AutoDL Guide.
- [2026.03]
Quickstart notebook released β reproduce flood nowcasting in < 2 minutes, no local GPU or dataset needed.
- [2026.03] LarNO benchmark datasets supported: train on Futian (Shenzhen, 20 m/5 min) and UKEA (UK, 8 m/5 min). See Section 6.
- [2026.03] Training speedup tips added: use the lightweight dataset (8 m / 10 min) for fast iteration β see Section 5.
- [2025.04] Peking University's official media promoted our work β Chinese | English.
- [2025.04] Paper online at ScienceDirect.
- [2025.03] U-RNN accepted by Journal of Hydrology.
- [2024.12] UrbanFlood24 dataset publicly released at official project page and Baidu Cloud (code: urnn).
U-RNN architecture. A U-like Encoder-Decoder with multi-scale ConvGRU cells processes spatiotemporal rainfall + terrain inputs. The Sliding Window-based Pre-warming (SWP) paradigm decomposes long sequences into overlapping windows for memory-efficient training.
| No local GPU? Try in your browser. The quickstart notebook runs end-to-end in < 2 min β no installation, no dataset download. Covers architecture demo and real inference. |
Or run locally in 3 commands:
# 1. Clone & install
git clone https://github.com/holmescao/U-RNN && cd U-RNN/code
pip install torch==2.0.0 torchvision==0.15.1 --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt
# 2. Download pre-trained weights (see Section 3) and dataset (see Section 2), then:
# 3. Run inference β results in exp/20240202_162801_962166/figs/
python test.py --exp_config configs/location1_scratch.yaml --timestamp 20240202_162801_962166
# Or use a lightweight checkpoint (see Section 3 for all available checkpoints)
python test.py --exp_config configs/lite.yaml --timestamp 20260316_130418_443889- Installation
- Dataset Preparation
- Pre-trained Weights
- Scenario A β Quick Inference with Pre-trained Weights
- Scenario B β Lightweight Training (Fast Iteration)
- Scenario C β LarNO Datasets Training (Futian & UKEA)
- Scenario D β Full Training (Paper Results)
- Inference with TensorRT (Optional)
- Project Structure
- Outputs
- Cloud GPU β AutoDL Guide
- License
- FAQ
- Citation
- Contributing
π» Step 1 β Clone the repository
git clone https://github.com/holmescao/U-RNN
cd codeπ» Step 2 β Create a conda environment
conda create -n urnn python=3.8
conda activate urnnπ» Step 3 β Install PyTorch
Install PyTorch 2.0.0 with CUDA 11.8 (tested on NVIDIA RTX 4090):
pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 \
--index-url https://download.pytorch.org/whl/cu118π¨π³ China users β add the Tsinghua mirror for faster pip downloads (PyTorch must still be installed from the official wheel URL above):
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
π» Step 4 β Install project dependencies
cd code # the inner code directory
pip install -r requirements.txtπ¦ Alternative β install as a package:
pip install -e . # editable install from pyproject.tomlThis makes
urnn-trainandurnn-testavailable as CLI commands.
TensorRT inference (optional): also run
pip install -r requirements_tensorrt.txtβ only needed for Section 8.
β Step 5 β Verify the installation
python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
# Expected: 2.0.0+cu118 TrueOther CUDA versions β other PyTorch + CUDA combinations will also work; check pytorch.org for the matching install command.
U-RNN supports training on three dataset sources:
| Dataset | From | Location | Resolution | Grid | Steps | Duration | Rainfall |
|---|---|---|---|---|---|---|---|
| UrbanFlood24 | U-RNN paper | China (3 catchments) | 2 m / 1 min | 500Γ500 | 360 | 6 h | Uniform (T,) |
| UrbanFlood24 Lite | U-RNN paper (downsampled) | China (3 catchments) | 8 m / 10 min | 128Γ128 | 36 | 6 h | Uniform (T,) |
| Futian | LarNO paper | Shenzhen, China | 20 m / 5 min | 400Γ560 | 72 | 6 h | Spatial (T,H,W) |
| UKEA | LarNO paper | UK | 8 m / 5 min | 52Γ120 | 36 | 3 h | Spatial (T,H,W) |
Official page: https://holmescao.github.io/datasets/urbanflood24
This is the primary dataset from the U-RNN paper. It contains design-storm flood simulations for 3 urbanised catchments (location1β3) in China, generated by the MIKE+ hydrodynamic solver at 2 m / 1 min resolution.
Download:
| Mirror | Link |
|---|---|
| Official page | https://holmescao.github.io/datasets/urbanflood24 |
Baidu Cloud (code: urnn) |
Download |
β οΈ The full dataset is ~115 GB. If storage or GPU memory is limited, use UrbanFlood24 Lite (see below) or Scenario B for fast iteration.
Placement:
Unzip and place the data under <U-RNN_HOME>/data/:
U-RNN/
βββ data/
β βββ urbanflood24/
β βββ train/
β β βββ flood/
β β β βββ location1/
β β β β βββ r100y_p0.5_d3h/
β β β β β βββ flood.npy
β β β β β βββ rainfall.npy
β β β β βββ ...
β β β βββ location2/
β β β βββ location3/
β β βββ geodata/
β β βββ location1/
β β β βββ absolute_DEM.npy
β β β βββ impervious.npy
β β β βββ manhole.npy
β β βββ location2/
β β βββ location3/
β βββ test/
β βββ ... (same structure)
βββ code/ β run all scripts from here
This is a downsampled version of UrbanFlood24 (spatial factor 4Γ, temporal factor 10Γ): 500Γ500β128Γ128, 360β36 steps. It is ~50Γ smaller and trains in ~30β45 min on a single RTX 4090, typically achieving RΒ²β0.91β0.99 (provided weights: 0.989; exact value varies with GPU/seed).
Download (contains only the 12 training/test events for location1β3):
| Mirror | Link |
|---|---|
| Google Drive | Download (no password) |
Baidu Cloud (code: urnn) |
Download |
Placement: same structure as UrbanFlood24, under data/urbanflood24_lite/.
Dataset 3 β Futian & UKEA (LarNO paper)
Official page: https://holmescao.github.io/datasets/LarNO
These datasets originate from the LarNO benchmark:
- Futian β Shenzhen urban catchment (20 m / 5 min, 400Γ560, spatial rainfall); location name:
region1 - UKEA β UK catchment (8 m / 5 min, 52Γ120, spatial design storms); location name:
ukea
Download from the official LarNO page β 4 mirrors available: Hugging Face, Google Drive, Baidu Cloud, Figshare.
After downloading, convert to U-RNN format:
cd code # the inner code directory
# Convert Futian (Shenzhen, China) β location name in output: region1
python tools/convert_larfno_data.py --dataset futian \
--larfno_root /path/to/larfno/futian \
--dst_root ../data/larfno_futian
# Convert UKEA (UK) β location name in output: ukea
python tools/convert_larfno_data.py --dataset ukea \
--larfno_root /path/to/larfno/ukea \
--dst_root ../data/ukea_8m_5min| File | Shape | Unit | Description |
|---|---|---|---|
flood.npy |
(T, H, W) |
metres | Ground-truth water depth from MIKE+ (converted to mm internally). |
rainfall.npy |
(T,) or (T, H, W) |
mm / step | Rainfall intensity per time step. Scalar (T,) for UrbanFlood24; spatial (T, H, W) for Futian / UKEA. |
absolute_DEM.npy |
(H, W) |
metres | Digital Elevation Model (terrain + buildings). |
impervious.npy |
(H, W) |
fraction [0, 1] | Impervious surface ratio. |
manhole.npy |
(H, W) |
{0, 1} | Drainage manhole locations. |
Training and test events are listed in plain text files under src/lib/dataset/:
| File | Dataset | Events |
|---|---|---|
train.txt / test.txt |
UrbanFlood24 (all locations) | 36 train / 12 test |
location1_train.txt / location1_test.txt |
UrbanFlood24 location1 | 8 train / 4 test |
location2_train.txt / location2_test.txt |
UrbanFlood24 location2 | 8 train / 4 test |
location3_train.txt / location3_test.txt |
UrbanFlood24 location3 | 8 train / 4 test |
futian_train.txt / futian_test.txt |
Futian | 4 train / 4 test |
ukea_train.txt / ukea_test.txt |
UKEA | 8 train / 12 test |
We provide pre-trained checkpoints for all supported datasets.
| Checkpoint | Dataset | Grid | Epochs | RΒ² | Size |
|---|---|---|---|---|---|
| Location1 full-res β | UrbanFlood24 location1 | 500Γ500 | 1000 | paper accuracy | ~300 MB |
| Location1 lite | UrbanFlood24 Lite location1 | 128Γ128 | 200 | 0.989 | ~20 MB |
| Futian | Futian (Shenzhen) | 400Γ560 | 200 | 0.888 | ~141 MB |
| UKEA | UKEA (UK) | 52Γ120 | 300 | 0.896 | ~11 MB |
| Mirror | Link |
|---|---|
| Google Drive | Download (no password) |
Baidu Cloud (code: urnn) |
Download |
| π€ Hugging Face Hub | Not included (full-res weights are very large; use Google Drive above) |
| Mirror | Link |
|---|---|
| Google Drive | Download (no password) |
Baidu Cloud (code: urnn) |
Download |
| π€ Hugging Face Hub | Download |
| Mirror | Link |
|---|---|
| Google Drive | Download (no password) |
Baidu Cloud (code: urnn) |
Download |
| π€ Hugging Face Hub | Download |
| Mirror | Link |
|---|---|
| Google Drive | Download (no password) |
Baidu Cloud (code: urnn) |
Download |
| π€ Hugging Face Hub | Download |
Each archive follows the same exp/<timestamp>/save_model/ structure. Extract and place as shown:
U-RNN/
βββ exp/
βββ 20240202_162801_962166/ β location1 full-res
β βββ save_model/
β βββ checkpoint_939_0.000205376.pth.tar
βββ 20260316_130418_443889/ β location1 lite
β βββ save_model/
β βββ checkpoint_143_0.065581453.pth.tar
βββ 20260316_134929_015563/ β Futian
β βββ save_model/
β βββ checkpoint_198_0.112292888.pth.tar
βββ 20260316_153558_270657/ β UKEA
βββ save_model/
βββ checkpoint_181_0.132711639.pth.tar
Pass the corresponding --timestamp when running inference:
# Location1 full-res (Scenario A)
python test.py --exp_config configs/location1_scratch.yaml --timestamp 20240202_162801_962166
# Location1 lite
python test.py --exp_config configs/lite.yaml --timestamp 20260316_130418_443889
# Futian
python test.py --exp_config configs/futian_scratch.yaml --timestamp 20260316_134929_015563
# UKEA
python test.py --exp_config configs/ukea_scratch.yaml --timestamp 20260316_153558_270657Requirements: pre-trained weights (Section 3) + corresponding dataset (Section 2) Β |Β any GPU Β |Β ~5 min
cd code # the inner code directory
# Location1 full-res (UrbanFlood24, 500Γ500)
python test.py --exp_config configs/location1_scratch.yaml --timestamp 20240202_162801_962166
# Location1 lite (UrbanFlood24 Lite, 128Γ128)
python test.py --exp_config configs/lite.yaml --timestamp 20260316_130418_443889
# Futian (Shenzhen, 400Γ560)
python test.py --exp_config configs/futian_scratch.yaml --timestamp 20260316_134929_015563
# UKEA (UK, 52Γ120)
python test.py --exp_config configs/ukea_scratch.yaml --timestamp 20260316_153558_270657For each test event, test.py saves a 3-row comparison figure to exp/<timestamp>/figs/epoch@<N>/<event>/water_depth_spatial_temporal.png:
| Row | Content | Colorbar |
|---|---|---|
| Reference | Ground-truth water depth (MIKE+) | 0β2 m (jet) |
| U-RNN | Model prediction | 0β2 m (jet) |
| Error | Absolute error |pred β ref| | 0β0.3 m (Reds) |
Time snapshots are configurable via --viz_time_points (space-separated zero-indexed integers).
For ~2β3Γ faster inference, see Section 8 β Inference with TensorRT.
Requirements: UrbanFlood24 Lite dataset (Section 2) Β |Β β₯ 8 GB VRAM Β |Β ~30β45 min on RTX 4090 (200 epochs)
This scenario trains on the 128Γ128 Γ 36 steps lightweight dataset (~50Γ smaller than full resolution). It is the recommended starting point for verifying your setup before committing to full training.
Download the lite dataset (Section 2), then:
cd code # the inner code directory
python main.py --exp_config configs/lite.yamlCUDA_VISIBLE_DEVICES=0,1 torchrun --nproc_per_node=2 main.py \
--exp_config configs/lite.yamlDDP gradients are averaged automatically across GPUs; effective batch size =
batch_size Γ world_size. Linux only (NCCL backend). On Windows use single-GPU.
The script creates exp/<timestamp>/ with:
exp/<timestamp>/
βββ save_model/ β model checkpoints (.pth.tar)
βββ save_train_loss/
βββ save_res_data/
βββ figs/ β test visualizations (if test: true in config)
Note the generated <timestamp> β you will need it to run inference on your own trained model:
python test.py --exp_config configs/lite.yaml \
--timestamp <your_timestamp>Requirements: LarNO dataset (Section 2) Β |Β β₯ 8β16 GB VRAM Β |Β 35 min β 5 h on RTX 4090
~5 h on RTX 4090 (200 epochs, 400Γ560 grid)
cd code # the inner code directory
# First convert the LarNO dataset (one-time):
python tools/convert_larfno_data.py --dataset futian \
--larfno_root /path/to/larfno/futian \
--dst_root ../data/larfno_futian
# Train:
python main.py --exp_config configs/futian_scratch.yaml~35 min on RTX 4090 (300 epochs, 52Γ120 grid)
# First convert the LarNO dataset (one-time):
python tools/convert_larfno_data.py --dataset ukea \
--larfno_root /path/to/larfno/ukea \
--dst_root ../data/ukea_8m_5min
# Train:
python main.py --exp_config configs/ukea_scratch.yamlCUDA_VISIBLE_DEVICES=0,1 torchrun --nproc_per_node=2 main.py \
--exp_config configs/futian_scratch.yamlDDP gradients are averaged automatically across GPUs; effective batch size =
batch_size Γ world_size. Linux only (NCCL backend). On Windows use single-GPU.
Requirements: full UrbanFlood24 dataset (Section 2) Β |Β β₯ 16 GB VRAM per location Β |Β ~6β12 h per location on RTX 4090 (1000 epochs)
U-RNN trains on one location at a time. To reproduce paper results, train each location separately:
cd code # the inner code directory
python main.py --exp_config configs/location1_scratch.yaml
python main.py --exp_config configs/location2_scratch.yaml
python main.py --exp_config configs/location3_scratch.yamlCUDA_VISIBLE_DEVICES=0,1 torchrun --nproc_per_node=2 main.py \
--exp_config configs/location1_scratch.yamlpython test.py --exp_config configs/location1_scratch.yaml \
--timestamp <your_timestamp>TensorRT accelerates inference by ~2β3Γ over PyTorch on the same GPU. This requires TensorRT 10.0.0.6.
python urnn_to_tensorrt.py --exp_config configs/location1_scratch.yaml \
--timestamp 20240202_162801_962166This creates exp/<timestamp>/tensorrt/URNN.trt.
python test.py --exp_config configs/location1_scratch.yaml \
--timestamp 20240202_162801_962166 --trtU-RNN/
βββ data/ β populate after downloading
β βββ urbanflood24/
β βββ train/
β β βββ flood/<location>/<event>/
β β β βββ flood.npy (T, H, W) metres
β β β βββ rainfall.npy (T,) or (T, H, W) mm/step
β β βββ geodata/<location>/
β β βββ absolute_DEM.npy (H, W) metres
β β βββ impervious.npy (H, W) fraction
β β βββ manhole.npy (H, W) binary
β βββ test/ β same structure
β
βββ exp/ β auto-created during training
β βββ <timestamp>/
β βββ save_model/ β checkpoints (.pth.tar)
β βββ save_train_loss/
β βββ save_res_data/
β βββ figs/epoch@<N>/ β inference visualizations (PNG)
β
βββ code/ β run all scripts from here
βββ main.py β training entry point
βββ test.py β inference entry point
βββ config.py β all hyperparameters (argparse + YAML)
βββ pyproject.toml β package definition (pip install -e .)
βββ urnn_to_tensorrt.py β PyTorch β TensorRT conversion
βββ requirements.txt
βββ notebooks/
β βββ quickstart.ipynb β Colab quickstart notebook
βββ configs/
β βββ lite.yaml β lightweight UrbanFlood24 (recommended start) β
β βββ location1_scratch.yaml β UrbanFlood24 location1 from scratch
β βββ location2_scratch.yaml β UrbanFlood24 location2 from scratch
β βββ location3_scratch.yaml β UrbanFlood24 location3 from scratch
β βββ futian_scratch.yaml β Futian (Shenzhen) from scratch
β βββ ukea_scratch.yaml β UKEA (UK) from scratch
β βββ network.yaml β model architecture shapes (rarely changed)
β βββ defaults/ β internal defaults (do not edit)
β β βββ training.yaml
β β βββ data.yaml
β βββ experiments/ β ablation / research configs (not for general use)
βββ tools/
β βββ downsample_dataset.py β lightweight dataset generator
β βββ convert_larfno_data.py β LarNO β U-RNN format converter
β βββ compare_metrics.py β U-RNN vs baseline metrics comparison
β
βββ src/lib/
βββ dataset/
β βββ Dynamic2DFlood.py β data loading (supports scalar + spatial rain)
β βββ train.txt β UrbanFlood24 training event list (all locations)
β βββ test.txt β UrbanFlood24 test event list (all locations)
β βββ location1_train.txt / location1_test.txt
β βββ location2_train.txt / location2_test.txt
β βββ location3_train.txt / location3_test.txt
β βββ futian_train.txt / futian_test.txt
β βββ ukea_train.txt / ukea_test.txt
βββ model/
β βββ networks/
β β βββ model.py β ED (Encoder-Decoder) architecture
β β βββ encoder.py β multi-scale encoder with ConvGRU
β β βββ decoder.py β multi-scale decoder with ConvGRU
β β βββ ConvRNN.py β ConvLSTM / ConvGRU cell
β β βββ net_params.py β architecture configuration
β β βββ losses.py β FocalBCE_and_WMSE loss
β β βββ head/flood_head.py β dual-output head (reg + cls)
β βββ earlystopping.py
βββ utils/
βββ distributed_utils.py β multi-GPU DDP utilities
βββ general.py
Training prints per-epoch loss and saves checkpoints to exp/<timestamp>/save_model/.
Example log line:
[ 939/1000] loss:0.000205376 | loss_reg:... | loss_cls:... | time:42.31 sec
For each test event, test.py saves a 3-row PNG to:
exp/<timestamp>/figs/epoch@<N>/
βββ <event_name>/
βββ water_depth_spatial_temporal.png
Figure layout: Row 1 = Reference (ground truth), Row 2 = U-RNN prediction, Row 3 = Absolute error. Rows 1β2 share a fixed 0β2 m colorbar; Row 3 uses 0β0.3 m.
Per-event metrics (RΒ², RMSE, MAE, CSI) are saved to exp/<timestamp>/metrics/metrics_epoch<N>.xlsx.
If you do not have a local GPU, rent one from AutoDL for approximately Β₯1β3 per hour. The guide below uses the browser-based JupyterLab β no additional software needed on your local machine.
β οΈ Download the dataset to your local machine first (see Section 2) before creating a cloud instance.
- Register and log in at https://www.autodl.com/.
- Click η§η¨ β GPU δΊζε‘ε¨.
- Choose a GPU with β₯ 24 GB VRAM for the full dataset (e.g., RTX 4090 24 GB).
- For the lightweight 8 m / 10 min dataset, β₯ 8 GB VRAM is sufficient.
- Select the base image: PyTorch 2.0 β Python 3.8 (ubuntu20.04) β CUDA 11.8.
- Click η«ε³εε»Ί and wait for the instance to start.
On the instance overview page, click the JupyterLab button. Use the terminal (Launcher β Terminal) to run shell commands.
cd /root/autodl-tmp/
git clone https://github.com/holmescao/U-RNNFind your SSH login command on the AutoDL instance overview page, e.g.:
ssh -p 12345 root@connect.westb.seetacloud.com
β οΈ The host, port, and password above are examples β use your own dashboard values.
# Upload the dataset zip
scp -P 12345 /local/path/urbanflood24.zip root@connect.westb.seetacloud.com:/root/autodl-tmp/
# Or rsync for large folders (resumes on failure):
rsync -avz --progress -e "ssh -p 12345" /local/path/urbanflood24/ \
root@connect.westb.seetacloud.com:/root/autodl-tmp/U-RNN/data/urbanflood24/scp -P 12345 C:\path\to\urbanflood24.zip root@connect.westb.seetacloud.com:/root/autodl-tmp/Or use WinSCP with Protocol = SCP.
cd /root/autodl-tmp/
unzip urbanflood24.zip
mv urbanflood24 U-RNN/data/
ls U-RNN/data/urbanflood24/train/flood/ # verifycd /root/autodl-tmp/U-RNN/code
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple# On your local machine:
scp -P 12345 /local/path/checkpoint_939_0.000205376.pth.tar \
root@connect.westb.seetacloud.com:/root/autodl-tmp/U-RNN/exp/20240202_162801_962166/save_model/cd /root/autodl-tmp/U-RNN/code
python test.py \
--exp_config configs/location1_scratch.yaml \
--timestamp 20240202_162801_962166Results appear in exp/20240202_162801_962166/figs/.
Scenario B β UrbanFlood24 lightweight dataset (128Γ128Γ36, ~30β45 min on one 4090):
cd /root/autodl-tmp/U-RNN/code
python main.py --exp_config configs/lite.yamlScenario C β Futian (Shenzhen, 400Γ560Γ72, ~5 h on one 4090):
cd /root/autodl-tmp/U-RNN/code
# First convert the LarNO dataset (one-time):
python tools/convert_larfno_data.py --dataset futian \
--larfno_root /root/autodl-tmp/data/larfno_futian \
--dst_root ../data/larfno_futian
# Train:
python main.py --exp_config configs/futian_scratch.yamlScenario C β UKEA (UK, 52Γ120Γ36, ~35 min on one 4090):
cd /root/autodl-tmp/U-RNN/code
# First convert the LarNO dataset (one-time):
python tools/convert_larfno_data.py --dataset ukea \
--larfno_root /root/autodl-tmp/data/larfno_ukea \
--dst_root ../data/ukea_8m_5min
# Train:
python main.py --exp_config configs/ukea_scratch.yamlScenario D β Full-resolution per-location (500Γ500Γ360, ~6β12 h per location on one 4090):
python main.py --exp_config configs/location1_scratch.yaml
python main.py --exp_config configs/location2_scratch.yaml
python main.py --exp_config configs/location3_scratch.yaml# On your local machine:
scp -P 12345 -r root@connect.westb.seetacloud.com:/root/autodl-tmp/U-RNN/exp/ \
/local/path/results/This project is released under the MIT License.
Q: Which scenario should I start with?
A: Follow this order:
- Scenario A β run inference with the pre-trained weights to verify your setup (requires full dataset, ~5 min).
- Scenario B β train on the lightweight dataset (~30β45 min) to confirm the training pipeline works end-to-end.
- Scenario C β train on LarNO datasets (Futian or UKEA) with pre-converted data.
- Scenario D β full training to reproduce paper accuracy (~40 hours).
Q: Training is very slow. How can I speed it up?
A: Three main levers:
- Reduce spatiotemporal resolution β use
tools/downsample_dataset.pyto create a downsampled dataset. A 4Γ spatial + 10Γ temporal reduction gives ~50Γ speedup (Scenario B). - Reduce epochs β the paper uses 1000 epochs, but 200 epochs with
prewarming=falsetypically achieves RΒ²β0.91β0.99 (provided weights reach 0.989), which is our recommended default. - Enable gradient checkpointing β add
--use_checkpointto reduce GPU memory and allow larger--seq_num.
Q: I get CUDA out-of-memory during training. What can I do?
A: Try any of the following:
- Add
--use_checkpoint(gradient checkpointing; already enabled in experiment YAMLs). - Reduce
--seq_num(e.g., from 28 to 14) to shorten each backward pass. - Use the lightweight dataset (Scenario B) to reduce input size.
- Reduce
--batch_size(default is already 1).
Q: What do I need to change when using my own dataset?
A: You need to:
- Prepare data files:
flood.npy(T, H, W),rainfall.npy(T,) or (T, H, W), and geodata files. - Put them under
data/<your_dataset>/train/flood/<location>/andgeodata/<location>/. - Create event list files
src/lib/dataset/<your>_train.txtand<your>_test.txt. - Copy an existing config (e.g.,
configs/lite.yaml) toconfigs/custom.yamland updatedata_root,input_height,input_width,window_size,duration, and normalization constants.
Q: How do I evaluate on a new location?
A: Train the model from scratch for that location (providing matching train.txt / test.txt). The architecture parameters (filter sizes, number of stages) do not depend on location and can be reused. Only normalization constants may need tuning for significantly different rainfall regimes.
Q: How do I run single-GPU vs multi-GPU training?
A: The same main.py entry point supports both modes automatically:
- Single GPU:
python main.py --exp_config ...β no launcher needed. - Multi-GPU (DDP):
torchrun --nproc_per_node=N main.py --exp_config ...βtorchrunsetsLOCAL_RANK/RANK/WORLD_SIZEautomatically.
Important β batch_size scaling rule: batch_size in the config is the per-GPU batch size.
The effective batch size = batch_size Γ N (number of GPUs).
Set batch_size equal to the number of GPUs you are using so that the effective batch
size scales proportionally with GPU count (e.g. 2 GPUs β batch_size: 2, 4 GPUs β batch_size: 4).
Note: python -m torch.distributed.launch (deprecated since PyTorch 1.9) also still works.
Q: Multi-GPU training doesn't work on Windows.
A: The NCCL backend requires Linux. On Windows, use single-GPU (python main.py ...) or WSL2 for multi-GPU.
Q: test.py says it can't find the checkpoint.
A: The --timestamp must match exactly the directory name under exp/. Check that exp/<timestamp>/save_model/ contains at least one checkpoint_*.pth.tar file.
Q: How do I change the visualization time points?
A: Pass --viz_time_points 0 60 120 180 (space-separated integers, zero-indexed). Make sure all indices are within [0, window_size - 1]. For the lightweight dataset (36 steps), use --viz_time_points 0 11 23 35.
Q: How do I use spatial (heterogeneous) rainfall?
A: Store rainfall.npy as shape (T, H, W) instead of (T,). The dataset loader detects the shape automatically β no config change needed. Futian and UKEA configs already use spatial rainfall.
Q: Does the code require exactly torch==2.0.0?
A: No. PyTorch 2.0.0 is the version tested on the development machine, but the code is compatible with PyTorch 2.1.x and later. If your environment already has a newer PyTorch version, you do not need to downgrade.
Q: I only have a subset of the test events (e.g., 1 event). Can I still run inference?
A: Yes. Create a custom test list file with just the event names you have:
echo 'r100y_p0.5_d3h' > code/src/lib/dataset/demo_test.txtThen pass it to test.py:
python test.py --exp_config configs/lite.yaml \
--timestamp 20260316_130418_443889 \
--test_list_file ./src/lib/dataset/demo_test.txtIf you find this project useful, please cite our paper and dataset:
@article{cao2025u,
title={U-RNN high-resolution spatiotemporal nowcasting of urban flooding},
author={Cao, Xiaoyan and Wang, Baoying and Yao, Yao and Zhang, Lin and Xing, Yanwen
and Mao, Junqi and Zhang, Runqiao and Fu, Guangtao
and Borthwick, Alistair GL and Qin, Huapeng},
journal={Journal of Hydrology},
pages={133117},
year={2025},
publisher={Elsevier}
}
@misc{cao2024supplementary,
author = {Cao, Xiaoyan and Wang, Baoying and Qin, Huapeng},
title = {Supplementary data of "U-RNN high-resolution spatiotemporal
nowcasting of urban flooding"},
year = {2024},
publisher = {figshare},
note = {Dataset}
}Contributions are welcome! See CONTRIBUTING.md for guidelines on bug reports, pull requests, and adding new datasets.
See CHANGELOG.md for the full history of changes.


