コンテンツにスキップ

AMD - ROCm

ROCm実行プロバイダーは、AMD ROCm対応GPU上でハードウェア加速計算を可能にします。

注意 ROCm 7.1以降、MicrosoftによるROCm実行プロバイダーのサポートは終了します。

アプリケーションをMIGraphX実行プロバイダーの使用に移行してください。

ROCm 7.0は、このプロバイダーの最後の公式AMD サポート配布版であり、今後のすべてのビルド(ROCm 7.1以降)ではROCm EPが削除されます。

背景については、このプルリクエストを参照してください。

注意 PyTorchバージョンで指定されている適切なバージョンのPytorchをインストールしてください。

ナイトリーPyTorchビルドについては、Pytorchホームを参照し、コンピュートプラットフォームとしてROCmを選択してください。

ROCm EPを含むONNX Runtimeのプリビルドバイナリは、ほとんどの言語バインディング用に公開されています。ORT のインストールを参照してください。

ビルド手順については、ビルドページを参照してください。プリビルド.whlファイルは以下の要件セクションで提供され、repo.radeon.comでホストされています。Ubuntuベースのdocker開発環境は、Dockerサポートセクションで提供されています。新しいwheelとdockerは各ROCmリリースで公開されます。

以下は、Ubuntuビルドに対応するサポートされているROCmバージョンのマトリックスです。

ROCm 6.0.2以降、プリビルドPython Wheels(.whl)のリンクは、Ubuntuサポートに基づくホストOSのPythonバージョンに対応して以下にリンクされています。 すべてのリンクは、各ROCmリリースに対応するAMDのrepo.radeon manylinuxページで見つけることができます。

ROCm 7.0は、ROCm実行プロバイダーを含む最後の公式サポートAMDリリースです。 代わりにアプリケーションにはMIGraphX実行プロバイダーを使用してください。

ONNX Runtime VersionROCm VersionPython 3.8Python 3.9Python 3.10Python 3.12
ONNX Runtime VersionMIGraphX ROCm ReleasePython 3.8Python 3.9Python 3.10Python 3.12
------------------
1.22.17.03.103.12
1.216.4.43.93.103.12
1.216.4.33.93.103.12
1.216.4.23.93.103.12
1.216.4.13.93.103.12
1.216.43.103.12
1.196.3.13.103.12
1.196.33.103.12
1.186.2.43.10
1.186.2.33.10
1.186.23.83.10
1.176.1.33.10
1.176.13.83.10
1.176.0.23.10
1.176.0
5.7
1.165.6
5.5
5.4.2
1.155.4.2
5.4
5.3.2
1.145.4
5.3.2
1.135.4
5.3.2
1.125.2.3
5.2

シンプルなワークロードやプロトタイピング用に、AMDは最新のROCmリリースとサポートされているROCm-Pytorchビルドを使用したUbuntuベースのDockerイメージを作成しています。ROCM Dockerhubで見つけることができます。

この目的は、ユーザーがPythonでカスタムワークロードを迅速に開始できるようにし、Onnxruntimeをビルドする必要なく開始するために必要なプリビルドROCm、Onnxruntime、MIGraphXパッケージの環境を提供することです。

ROCm実行プロバイダーは以下の設定オプションをサポートしています。

デバイスID。

デフォルト値:0

TunableOpを使用するように設定します。

デフォルト値:false

TunableOpがオンラインチューニングを試行するように設定します。

デフォルト値:false

Defines the compute stream for the inference to run on. It implicitly sets the has_user_compute_stream option. It cannot be set through UpdateROCMProviderOptions. This cannot be used in combination with an external allocator.

Example python usage:

providers = [("ROCMExecutionProvider", {"device_id": torch.cuda.current_device(),
"user_compute_stream": str(torch.cuda.current_stream().cuda_stream)})]
sess_options = ort.SessionOptions()
sess = ort.InferenceSession("my_model.onnx", sess_options=sess_options, providers=providers)

To take advantage of user compute stream, it is recommended to use I/O Binding to bind inputs and outputs to tensors in device.

Whether to do copies in the default stream or use separate streams. The recommended setting is true. If false, there are race conditions and possibly better performance.

Default value: true

The size limit of the device memory arena in bytes. This size limit is only for the execution provider’s arena. The total device memory usage may be higher. s: max value of C++ size_t type (effectively unlimited)

Note: Will be over-ridden by contents of default_memory_arena_cfg (if specified)

The strategy for extending the device memory arena.

ValueDescription
kNextPowerOfTwo (0)subsequent extensions extend by larger amounts (multiplied by powers of two)
kSameAsRequested (1)extend by the requested amount

Default value: kNextPowerOfTwo

Note: Will be over-ridden by contents of default_memory_arena_cfg (if specified)

gpu_external_* is used to pass external allocators. Example python usage:

from onnxruntime.training.ortmodule.torch_cpp_extensions import torch_gpu_allocator
provider_option_map["gpu_external_alloc"] = str(torch_gpu_allocator.gpu_caching_allocator_raw_alloc_address())
provider_option_map["gpu_external_free"] = str(torch_gpu_allocator.gpu_caching_allocator_raw_delete_address())
provider_option_map["gpu_external_empty_cache"] = str(torch_gpu_allocator.gpu_caching_allocator_empty_cache_address())

Default value: 0

Ort::Env env = Ort::Env{ORT_LOGGING_LEVEL_ERROR, "Default"};
Ort::SessionOptions so;
int device_id = 0;
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_ROCm(so, device_id));

C APIの詳細はこちらにあります。

Python APIの詳細はこちらにあります。

import onnxruntime as ort
model_path = '<path to model>'
providers = [
'ROCMExecutionProvider',
'CPUExecutionProvider',
]
session = ort.InferenceSession(model_path, providers=providers)