TargetDevice

TargetDevice

is an option for certain functions that specifies whether CPU or GPU computation should be attempted.

Details

  • Typically possible settings are "CPU" and "GPU".
  • TargetDevice can be used with NetTrain to determine on which device a network is trained.
  • TargetDevice can be supplied when applying a trained neural net to an input to determine on which device the network is evaluated.
  • With the setting TargetDevice->"GPU", the Wolfram Language will attempt to use a GPU if it is available on your computer.
  • TargetDevice{"GPU",n} allows a specific GPU to be used, where n is an integer between 1 and the number of GPUs available on your computer.
  • TargetDevice->{"GPU",All} specifies that all available GPUs should be used jointly.
  • TargetDevice->{"GPU",{n1,n2,}} specifies that a specific subset of the GPUs should be used jointly.
  • Only NVIDIA GPUs with the following compute capabilities are currently supported:
  • Capability 3.7Kepler architectureTesla K80
    Capability 5.0Maxwell architectureGTX 750 etc.
    Capability 5.2Maxwell architectureGTX 980 etc.
    Capability 6.0Pascal architectureTesla P100 etc.
    Capability 6.1Pascal architectureGTX 1080 etc.
    Capability 7.0Volta architectureTesla V100 etc.
    Capability 7.5Turing architectureRTX 2080 etc.
    Capability 8.0Ampere architectureTesla A100 etc.
    Capability 8.6Ampere architectureRTX 3080 etc.
  • In a fresh Wolfram Language installation, TargetDevice->"GPU" and related GPU settings will automatically download additional libraries ("MXNetResources"). Such a download can also trigger again in case updates are available. The download can also be started manually by running PacletInstall["MXNetResources"].

Examples

open allclose all

Basic Examples  (1)

Train a net using the system's default GPU:

Evaluate the resulting net using the system's default GPU:

Scope  (1)

Train a net using a specified GPU:

Train a net using two specified GPUs, where each GPU receives a batch of 16 training examples per training iteration:

Train a net using all available GPUs:

Possible Issues  (1)

If the system GPU is not supported, the operation will fail:

Wolfram Research (2016), TargetDevice, Wolfram Language function, https://reference.wolfram.com/language/ref/TargetDevice.html (updated 2019).

Text

Wolfram Research (2016), TargetDevice, Wolfram Language function, https://reference.wolfram.com/language/ref/TargetDevice.html (updated 2019).

CMS

Wolfram Language. 2016. "TargetDevice." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. 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_2023_targetdevice, author="Wolfram Research", title="{TargetDevice}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/TargetDevice.html}", note=[Accessed: 19-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_targetdevice, organization={Wolfram Research}, title={TargetDevice}, year={2019}, url={https://reference.wolfram.com/language/ref/TargetDevice.html}, note=[Accessed: 19-April-2024 ]}