ある種の関数のオプションで,どのデバイスで計算をすべきかを指定する.
TargetDevice
ある種の関数のオプションで,どのデバイスで計算をすべきかを指定する.
詳細
- TargetDeviceの可能な設定は,システムと利用可能なハードウェアに応じて変る.
- 次は,一般的な設定である.
-
"CPU" CPUを使う "GPU" 使用可能な専用ハードウェアを使う - TargetDevice->"GPU"の指定は,$SystemIDによって以下のいずれかに解決される.
-
"CoreML" "MacOSX-ARM64" "CUDA" "Windows-x86-64"または"Linux-x86-64" "DirectML" CUDAが検出されない場合は"Windows-x86-64" - 次は,使用可能な設定の完全リストである.
-
"CPU" デフォルトのCPU "CoreML" Apple CoreMLフレームワーク "CUDA" Nvidia CUDA API "DirectML" Microsoft Direct Machine Learning API {device,n} 整数ID n の物理的なデバイスを使う {device,{n1,…}} 複数のデバイスを共同で使う {device,All} 使用可能な全デバイスを共同で使う - {device, _}の形式の指定は,device が"CUDA"または"DirectML"に解決する場合にのみサポートされる.
- 複数デバイスの使用は,NetTrainを使った訓練でのみサポートされる
- デバイス識別子 n は,1から使用可能な物理デバイス数までの整数である.
- 一般に,"CUDA"や"DirectML"のような異なるバックエンドが使用されている場合は,n の特定の値が同じGPUを特定しない場合もある.
- Appleシリコンマシン上では,TargetDevice->"CoreML"はApple Neural Engineを使って計算しようとする. »
- Windowsマシン上では,TargetDevice->"DirectML"は,DirectXをサポートする統合されたあるいは個別のGPUを使って計算することができる.
- 現在NetTrainおよびNetMeasurementsでサポートされる設定は,"CPU"および"CUDA"だけである.
- TargetDevice"CUDA"は,計算性能が5.0以上のNVIDIA GPUを必要とする.
- LinuxおよびWindowsのマシンにWolfram言語を新たにインストールするとTargetDevice->"GPU"および関連GPU設定で追加的なライブラリが自動的にダウンロードされる.このようなダウンロードはアップデートの際にもトリガされる.ダウンロードは,PacletInstall["NeuralNetworkResources"]およびPacletInstall["WolframGPUSDK"]を実行することで手動で始めることもできる.
例題
すべて開く すべて閉じる例 (1)
スコープ (6)
インターフェース (5)
NetModel["Wolfram ImageIdentify Net V1"][RandomImage[], TargetDevice -> "CPU"]NetModel["Wolfram ImageIdentify Net V1"][RandomImage[], TargetDevice -> "GPU"]NetModel["Wolfram ImageIdentify Net V1"][RandomImage[], TargetDevice -> "CoreML"]DirectML互換のカードを指定する(Windows x86-64):
NetModel["Wolfram ImageIdentify Net V1"][RandomImage[], TargetDevice -> "DirectML"]CUDA互換のカードの使用を指定する(Windows x86-64またはLinux x86-64):
NetModel["Wolfram ImageIdentify Net V1"][RandomImage[], TargetDevice -> "CUDA"]訓練 (1)
NetTrain[NetModel["LeNet"], "MNIST", TargetDevice -> {"GPU", 1}]指定した2つのGPUを使ってネットを訓練する.各GPUはトレーニングの反復ごとに16個のトレーニング例のバッチを受け取る:
NetTrain[NetModel["LeNet"], "MNIST", TargetDevice -> {"GPU", {1, 2}}, BatchSize -> 32]NetTrain[NetModel["LeNet"], "MNIST", TargetDevice -> {"GPU", All}, BatchSize -> 64]考えられる問題 (3)
この操作は,システムのGPUがサポートされていない場合は失敗する:
n = 100000;
trainingData = RandomReal[1, {n, 4}] -> RandomReal[1, {n, 4}];
net = NetChain[{8, Tanh, 2048, Tanh, 2048, Tanh, 4}, "Input" -> 4];
trained = NetTrain[net, trainingData, TargetDevice -> "GPU"]設定の中にはモデルの評価についてしかサポートされておらず訓練中に失敗するものもある:
NetTrain[NetModel["LeNet"], "MNIST", TargetDevice -> "CoreML"]NetTrain[NetModel["LeNet"], "MNIST", TargetDevice -> "CUDA"]テクニカルノート
関連するガイド
関連するワークフロー
- GPU上でニューラルネットワークの訓練を行う
テキスト
Wolfram Research (2016), TargetDevice, Wolfram言語関数, https://reference.wolfram.com/language/ref/TargetDevice.html (2024年に更新).
CMS
Wolfram Language. 2016. "TargetDevice." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/TargetDevice.html.
APA
Wolfram Language. (2016). TargetDevice. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TargetDevice.html
BibTeX
@misc{reference.wolfram_2026_targetdevice, author="Wolfram Research", title="{TargetDevice}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/TargetDevice.html}", note=[Accessed: 06-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_targetdevice, organization={Wolfram Research}, title={TargetDevice}, year={2024}, url={https://reference.wolfram.com/language/ref/TargetDevice.html}, note=[Accessed: 06-November-2026]}