WOLFRAM

GPUArray[array]

yields an array stored in memory accessible for GPU-accelerated computation.

Details

  • GPUArray provides an efficient representation for storing and manipulating data accessible from a graphics processor unit (GPU).
  • GPUArray is typically used to enhance speed of execution of functions by running computations on the GPU.
  • GPUArray[array] creates an array in GPU memory or unified memory.
  • The array can have the following forms:
  • {e1,},{{e1,},},full array of numeric elements
    NumericArray[]numeric array of a specified type
  • Normal[GPUArray[array]] converts the GPUArray object to an ordinary list of values.
  • Additional conversions include:
  • SparseArray[GPUArray[]]sparse array with few nonzero elements
    NumericArray[GPUArray[],type]numeric array of a specified type
  • Information for a GPUArray includes the following properties:
  • "ElementType"element native type
    "Dimensions"list of the dimensions
  • Functions such as LinearSolve, Plus and Part work on GPUArray by running the computation on the GPU.
  • GPUArray is treated as a raw object by functions like AtomQ and for purposes of pattern matching.

Examples

open allclose all

Basic Examples  (1)Summary of the most common use cases

Create a GPUArray object from a vector:

Out[1]=1

Compute the cosine:

Out[2]=2

Converts to an ordinary list of values:

Out[3]=3

Scope  (27)Survey of the scope of standard use cases

Basic Uses  (4)

Create a GPUArray object from a vector:

Out[2]=2

From a matrix:

Out[3]=3

Use NumericArray to create a GPUArray object of a specified type:

Out[1]=1

64-bit integers:

Out[2]=2

Convert a GPUArray object to an ordinary list of values:

Out[1]=1
Out[2]=2

Convert to a NumericArray object:

Out[3]=3

Convert to a SparseArray:

Out[4]=4

Get information of a GPUArray object:

Out[1]=1

Dimensions:

Out[2]=2

Type of elements:

Out[3]=3

Arrays Operations  (3)

Test whether a GPUArray object is a vector:

Out[5]=5
Out[2]=2

A matrix:

Out[3]=3
Out[4]=4

Extract parts of a GPUArray object:

Out[1]=1
Out[2]=2
Out[3]=3

Get properties of a GPUArray object:

Out[1]=1

Dimensions:

Out[2]=2

Depth:

Out[3]=3

Byte count:

Out[4]=4

Mathematical Operations  (6)

Apply arithmetic operations on GPUArray objects:

Addition:

Out[3]=3

Multiplication:

Out[4]=4

Power:

Out[5]=5

Evaluate numerically trigonometric functions:

Sine:

Out[2]=2

Cosine:

Out[3]=3

Arc cosine:

Out[4]=4

Compute transcendental functions:

Exp:

Out[2]=2

Log:

Out[3]=3

Power:

Out[4]=4

Evaluate efficiently hyperbolic functions:

Sinh:

Out[2]=2

Cosh:

Out[3]=3

Inverse cosine:

Out[4]=4

Evaluate numerically integer functions:

Ceiling:

Out[2]=2

Floor:

Out[3]=3

Round:

Out[4]=4

Compute absolute values and signs functions:

Abs:

Out[2]=2

Sign:

Out[3]=3

Absolute value of the real:

Out[4]=4

Fourier Analysis  (2)

Find a discrete Fourier transform:

Out[10]=10
Out[11]=11

Inverse Fourier transform of a complex list:

Out[1]=1
Out[2]=2

Statistics  (3)

Evaluate statistics functions on a GPUArray object:

Mean:

Out[12]=12

Geometric mean:

Out[13]=13

Variance:

Out[14]=14

Standard deviation:

Out[15]=15

Skewness:

Out[16]=16

Minimum of a GPUArray object:

Out[2]=2

Maximum:

Out[3]=3

Minimum and maximum:

Out[4]=4

Sort a GPUArray object:

Out[2]=2

Linear Algebra  (4)

Apply matrix operations on GPUArray objects:

Dot product:

Out[6]=6

Transpose:

Out[7]=7

Trace:

Out[10]=10

Solve a matrix-vector equation:

Out[3]=3

A matrix equation:

Out[6]=6

Solve a matrix-vector least-squares problem:

Out[1]=1

Solve a matrix-matrix least-squares problem:

Out[2]=2

Compute the singular value decomposition of a complex-valued matrix:

Out[2]=2

Up to expected precision loss, m=u.sigma.TemplateBox[{v}, ConjugateTranspose]:

Out[3]=3

Random Number Generation  (2)

Switch to the GPU random number generator:

Out[1]=1

Random numbers are now generated using it:

Out[2]=2

Random integers:

Out[3]=3

Random complexes:

Out[4]=4

A specific seed will affect the current GPU random number generator:

Out[1]=1

Visualization  (3)

Plot a list of values from a continuous probability distribution:

Out[7]=7
Out[8]=8

Plot an array of numbers:

Out[1]=1

Plot a matrix as an array of colors:

Out[1]=1

Properties & Relations  (4)Properties of the function, and connections to other functions

Use GPUArrayQ to test whether an object is a valid GPUArray object:

Out[1]=1
Out[2]=2

Find the number of bytes used to store a GPUArray object:

Out[1]=1
Out[2]=2

Use Normal to retrieve data from GPU:

Out[1]=1
Out[2]=2

GPUArray preserves representation types of elements in NumericArray objects:

Out[1]=1
Out[2]=2

Element type:

Out[3]=3

Possible Issues  (2)Common pitfalls and unexpected behavior

GPUArray autoevaluates if no supported GPUs were detected:

Out[1]=1

Operations without GPU-accelerated support fall back to CPU implementations:

Out[2]=2
Wolfram Research (2025), GPUArray, Wolfram Language function, https://reference.wolfram.com/language/ref/GPUArray.html.
Wolfram Research (2025), GPUArray, Wolfram Language function, https://reference.wolfram.com/language/ref/GPUArray.html.

Text

Wolfram Research (2025), GPUArray, Wolfram Language function, https://reference.wolfram.com/language/ref/GPUArray.html.

Wolfram Research (2025), GPUArray, Wolfram Language function, https://reference.wolfram.com/language/ref/GPUArray.html.

CMS

Wolfram Language. 2025. "GPUArray." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GPUArray.html.

Wolfram Language. 2025. "GPUArray." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GPUArray.html.

APA

Wolfram Language. (2025). GPUArray. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GPUArray.html

Wolfram Language. (2025). GPUArray. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GPUArray.html

BibTeX

@misc{reference.wolfram_2025_gpuarray, author="Wolfram Research", title="{GPUArray}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/GPUArray.html}", note=[Accessed: 07-May-2025 ]}

@misc{reference.wolfram_2025_gpuarray, author="Wolfram Research", title="{GPUArray}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/GPUArray.html}", note=[Accessed: 07-May-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_gpuarray, organization={Wolfram Research}, title={GPUArray}, year={2025}, url={https://reference.wolfram.com/language/ref/GPUArray.html}, note=[Accessed: 07-May-2025 ]}

@online{reference.wolfram_2025_gpuarray, organization={Wolfram Research}, title={GPUArray}, year={2025}, url={https://reference.wolfram.com/language/ref/GPUArray.html}, note=[Accessed: 07-May-2025 ]}