免責聲明該項目是測試版,並將在可預見的未來進行實驗。介面和功能可能會發生變化,項目本身可能會被廢棄。請勿在任何可運作的專案/軟體中使用此軟體。
ai-models
指令用於運行基於 AI 的天氣預報模型。這些模型需要獨立安裝。
儘管原始碼ai-models
及其外掛程式可在開源許可證下使用,但某些模型權重可能在不同的許可證下可用。例如,某些模型在 CC-BY-NC-SA 4.0 授權下提供其權重,該授權不允許商業用途。有關更多信息,請在其主頁上檢查與每個模型相關的許可證,我們從每個相應的插件連結到該許可證。
在使用ai-models
命令之前,請確保您符合以下先決條件:
要安裝ai-models
命令,請執行以下命令:
pip install ai-models
目前可安裝四種型號:
pip install ai-models-panguweather
pip install ai-models-fourcastnet
pip install ai-models-graphcast # Install details at https://github.com/ecmwf-lab/ai-models-graphcast
pip install ai-models-fourcastnetv2
有關這些模型的更多詳細信息,請參閱 ai-models-panguweather、ai-models-fourcastnet、ai-models-fourcastnetv2 和 ai-models-graphcast。
要運行模型,請確保它已安裝,然後只需運行:
ai-models < model-name >
將<model-name>
替換為您要執行的特定 AI 模型的名稱。
預設情況下,該模型將使用 ECMWF 的 MARS 檔案中昨天的 12Z 分析運行 10 天(240 小時)。
若要產生 15 天的預測,請使用--lead-time HOURS
選項:
ai-models --lead-time 360 < model-name >
您可以使用可用的命令列選項來變更其他預設值,如下所述。
AI模型可以在CPU上運作;然而,它們在 GPU 上的性能要好得多。 10 天的預測在 CPU 上可能需要幾個小時,但在現代 GPU 上只需要大約一分鐘。
如果您在執行模型時看到以下訊息,則表示 ONNX 執行時間無法在您的系統上找到 CUDA 庫:
[W:onnxruntime:默認,onnxruntime_pybind_state.cc:541 CreateExecutionProviderInstance] 無法建立 CUDAExecutionProvider。請參考 https://onnxruntime.ai/docs/reference/execution-providers/CUDA-ExecutionProvider.html#requirements 以確保滿足所有依賴項。
要解決此問題,我們建議您在 conda 環境中安裝ai-models
並在該環境中安裝 CUDA 庫。例如:
conda create -n ai-models python=3.10
conda activate ai-models
conda install cudatoolkit
pip install ai-models
...
人工智慧模型依賴於訓練期間創建的權重和其他資產。第一次運行模型時,您將需要下載經過訓練的權重和任何其他所需的資產。
若要在運行模型之前下載資產,請使用以下命令:
ai-models --download-assets < model-name >
如果需要,將下載資產並將其儲存在目前目錄中。您可以提供不同的目錄來儲存資產:
ai-models --download-assets --assets < some-directory > < model-name >
然後,稍後,只需使用:
ai-models --assets < some-directory > < model-name >
或者
export AI_MODELS_ASSETS= < some-directory >
ai-models < model-name >
為了更好地組織資產目錄,您可以使用--assets-sub-directory
選項。此選項會將每個模型的資產儲存在指定資產目錄內自己的子目錄中。
這些模型需要輸入資料(初始條件)才能運作。您可以使用不同的來源提供輸入數據,如下所述:
預設情況下, ai-models
使用昨天來自 ECMWF 的 12Z 分析,該分析是使用 ECMWF WebAPI 從中心的 MARS 檔案中取得的。您將需要一個 ECMWF 帳戶才能存取該服務。
若要變更日期或時間,請分別使用--date
和--time
選項:
ai-models --date YYYYMMDD --time HHMM < model-name >
您可以使用哥白尼氣候資料儲存 (CDS) 的 ERA5(ECMWF 再分析版本 5)資料啟動模型。您需要在 CDS 上建立帳戶。數據將使用 CDS API 下載。
要存取 CDS,只需在命令列上新增--input cds
即可。請注意,ERA5 資料會延遲新增至 CDS,因此您也必須使用--date YYYYMMDD
提供日期。
ai-models --input cds --date 20230110 --time 0000 < model-name >
如果您有 GRIB 格式的輸入數據,則可以使用--file
選項提供該檔案:
ai-models --file < some-grib-file > < model-name >
GRIB 檔案可以包含比模型所需的欄位更多的欄位。 ai-models
指令將自動從檔案中選擇必要的欄位。
若要尋找特定模型作為初始條件所需的欄位列表,請使用以下命令:
ai-models --fields < model-name >
預設情況下,模型輸出將以 GRIB 格式寫入名為<model-name>.grib
的檔案中。您可以使用選項--path <file-name>
更改檔案名稱。如果您指定的路徑包含{
和}
之間的佔位符,則會根據 eccodes 鍵建立多個檔案。例如:
ai-models --path ' out-{step}.grib ' < model-name >
此命令將為每個預測時間步建立一個檔案。
如果要禁止將輸出寫入文件,請使用--output none
選項。
它有以下選項:
--help
:顯示此說明訊息。--models
:列出所有已安裝的型號。--debug
:開啟偵錯模式。這會將附加資訊列印到控制台。--input INPUT
:模型的輸入來源。這可以是mars
、 cds
或file
。
--file FILE
:用作輸入的特定檔案。此選項將--source
設定為file
。
--date DATE
:模型的分析日期。這預設為昨天。
--time TIME
:模型的分析時間。預設為 1200。
--output OUTPUT
:模型的輸出目標。值為file
或none
。--path PATH
:寫入模型輸出的路徑。--lead-time HOURS
:預測的小時數。預設值為 240(10 天)。--assets ASSETS
:指定包含模型資產的目錄的路徑。預設為目前目錄,但您可以透過設定$AI_MODELS_ASSETS
環境變數來覆寫它。--assets-sub-directory
:允許在<assets-directory>/<model-name>
子目錄中組織資產。--download-assets
:如果資源不存在,下載資源。--fields
:列印模型所需的欄位清單作為初始條件。--expver EXPVER
:模型輸出的實驗版本。--class CLASS
:模型輸出的「類別」元資料。--metadata KEY=VALUE
:模型輸出中的附加元資料元資料 Copyright 2022, European Centre for Medium Range Weather Forecasts.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
In applying this licence, ECMWF does not waive the privileges and immunities
granted to it by virtue of its status as an intergovernmental organisation
nor does it submit to any jurisdiction.