# \#cuarrays

**URL:** https://discourse.julialang.org/tag/cuarrays/361.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Batched Matrix Multiply](https://discourse.julialang.org/t/batched-matrix-multiply/42332)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 12\
**Last updated:** [October 30, 2025, 8:22am UTC](https://discourse.julialang.org/t/batched-matrix-multiply/42332 "2025-10-30T08:22:15Z")

</div>

I’d like to be able to be able to broadcast matrix multiplication across multidimensional arrays similar to the following: a = rand(4,3,2) b = rand(3,4,2) a .\* b # expect a (4,4,2) array, but instead errors I underst…

---

## [Unable to sum CuArray with Julia 1.10.0](https://discourse.julialang.org/t/unable-to-sum-cuarray-with-julia-1-10-0/109100)

<div class="topic-metadata">

**Author:** [@Avec](https://discourse.julialang.org/u/Avec)\
**Replies:** 3\
**Last updated:** [January 24, 2024, 1:56pm UTC](https://discourse.julialang.org/t/unable-to-sum-cuarray-with-julia-1-10-0/109100 "2024-01-24T13:56:09Z")

</div>

Hi all, I have just updated my julia from 1.8.3 to 1.10.1 an I struggle with summing a CuArray. Following lines k\_ssim = exp.(-(-5:1:5).^2/(2\*1.5^2)) k\_ssim = k\_ssim |\> gpu sum(k\_ssim) returns LoadError: MethodError: …

---

## [Generic array code that works with CUDA and Zygote?](https://discourse.julialang.org/t/generic-array-code-that-works-with-cuda-and-zygote/104295)

<div class="topic-metadata">

**Author:** [@mchitre](https://discourse.julialang.org/u/mchitre)\
**Replies:** 0\
**Last updated:** [September 27, 2023, 7:22am UTC](https://discourse.julialang.org/t/generic-array-code-that-works-with-cuda-and-zygote/104295 "2023-09-27T07:22:22Z")

</div>

I am interested in writing a generic function that operates on an AbstractArray and produces some output. In doing so, it needs to create an intermediate array. The function should work with CPU arrays and GPU arrays, an…

---

## [Invalid Argument Error on 3D Array](https://discourse.julialang.org/t/invalid-argument-error-on-3d-array/99147)

<div class="topic-metadata">

**Author:** [@huiyuxie](https://discourse.julialang.org/u/huiyuxie)\
**Replies:** 4\
**Last updated:** [May 23, 2023, 10:26pm UTC](https://discourse.julialang.org/t/invalid-argument-error-on-3d-array/99147 "2023-05-23T22:26:23Z")

</div>

Hi! I am working on using CUDA.jl to write kernels for 1D, 2D, and 3D arrays. The kernel worked well for 1D and 2D arrays and here is the 2D code. using CUDA function gpu\_add1!(y, x) index\_i = (blockIdx().x - 1) \* blo…

---

## [Collect for CuArray composite types](https://discourse.julialang.org/t/collect-for-cuarray-composite-types/99082)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 2\
**Last updated:** [May 19, 2023, 11:46am UTC](https://discourse.julialang.org/t/collect-for-cuarray-composite-types/99082 "2023-05-19T11:46:44Z")

</div>

Using CUDA.jl single index access is discouraged for good reasons. However, if I want to implement a composite type (e.g. ShiftedArrays.jl) to work well with CuArray it needs to support collect. Yet the collect mechanis…

---

## [How to create sliced views of \`CuArray\` correctly?](https://discourse.julialang.org/t/how-to-create-sliced-views-of-cuarray-correctly/93971)

<div class="topic-metadata">

**Author:** [@jinfreedom](https://discourse.julialang.org/u/jinfreedom)\
**Replies:** 1\
**Last updated:** [February 3, 2023, 9:38pm UTC](https://discourse.julialang.org/t/how-to-create-sliced-views-of-cuarray-correctly/93971 "2023-02-03T21:38:45Z")

</div>

Hi, I would like to split and reshape a CuArray to a StructArray “in place” as views. I used sliced views of the input CuArray and got a warning about slicing. Is there a correct way of doing the following? julia\> siz=(…

---

## [CUDA How to limit the gpu memory available?](https://discourse.julialang.org/t/cuda-how-to-limit-the-gpu-memory-available/90599)

<div class="topic-metadata">

**Author:** [@Ludovic\_Dumoulin](https://discourse.julialang.org/u/Ludovic_Dumoulin)\
**Replies:** 7\
**Last updated:** [November 25, 2022, 9:56am UTC](https://discourse.julialang.org/t/cuda-how-to-limit-the-gpu-memory-available/90599 "2022-11-25T09:56:12Z")

</div>

Hello, With other lab members we share a jupyter hub server with a single gpu (A30). The problem is that when one is using FFTW or CuArray operations he fills the entire memory. When one runs a code with only low leve…

---

## [CUDA on slices](https://discourse.julialang.org/t/cuda-on-slices/86782)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 5\
**Last updated:** [September 6, 2022, 2:45am UTC](https://discourse.julialang.org/t/cuda-on-slices/86782 "2022-09-06T02:45:33Z")

</div>

Trying to apply a function to slices of a CuArray. Tried broadcasting, mapslices and various Tensor packages. Is there any way to do this? using CUDA, Pipe, Interpolations, TensorCast d = Uniform(1,30) x = Float64.(1…

---

## [Cross-platform (CPU/GPU) data structure for linear algebra](https://discourse.julialang.org/t/cross-platform-cpu-gpu-data-structure-for-linear-algebra/79877)

<div class="topic-metadata">

**Author:** [@FireCrumb](https://discourse.julialang.org/u/FireCrumb)\
**Replies:** 3\
**Last updated:** [May 13, 2022, 7:26am UTC](https://discourse.julialang.org/t/cross-platform-cpu-gpu-data-structure-for-linear-algebra/79877 "2022-05-13T07:26:20Z")

</div>

Hi, I’m building an ML application, and want to pass around a data structure that contains several scalars/arrays/vertices/matrices. The dimension will be determined at runtime, depending on input dataset etc. The nume…

---

## [Calculating crossentropy with varying sized vectors on GPU](https://discourse.julialang.org/t/calculating-crossentropy-with-varying-sized-vectors-on-gpu/79700)

<div class="topic-metadata">

**Author:** [@Casper](https://discourse.julialang.org/u/Casper)\
**Replies:** 0\
**Last updated:** [April 19, 2022, 4:15pm UTC](https://discourse.julialang.org/t/calculating-crossentropy-with-varying-sized-vectors-on-gpu/79700 "2022-04-19T16:15:08Z")

</div>

Hello, I’m attempting to calculate the cross entropy of a bunch of samples of different length. using CUDA entropy(π̂, π) =-sum(π .\* log.(π̂ )) m = 3 n = 3 w = ones(m) |\> gpu a1 = rand(Float32, m, n) a1 = softmax(a…

---

## [CUDA.jl - Sub-Vector Indexing Problem Inside CUDA Kernel](https://discourse.julialang.org/t/cuda-jl-sub-vector-indexing-problem-inside-cuda-kernel/78526)

<div class="topic-metadata">

**Author:** [@moukann](https://discourse.julialang.org/u/moukann)\
**Replies:** 2\
**Last updated:** [March 28, 2022, 11:13am UTC](https://discourse.julialang.org/t/cuda-jl-sub-vector-indexing-problem-inside-cuda-kernel/78526 "2022-03-28T11:13:18Z")

</div>

Hello all, I’ve been experimenting with CUDA Julia. Formerly, I used CUDA Python but it was so limited and restrictive. So I migrated to Julia. Thanks for the great effort and flexible framework to everybody working on …

---

## [CuArray only supports element types that are stored inline?](https://discourse.julialang.org/t/cuarray-only-supports-element-types-that-are-stored-inline/71339)

<div class="topic-metadata">

**Author:** [@Ludovic\_Dumoulin](https://discourse.julialang.org/u/Ludovic_Dumoulin)\
**Replies:** 1\
**Last updated:** [November 11, 2021, 5:23pm UTC](https://discourse.julialang.org/t/cuarray-only-supports-element-types-that-are-stored-inline/71339 "2021-11-11T17:23:19Z")

</div>

Hello, I would like to define, a mutable structure with a field of type ::CuArray{an\_other\_mutable\_structure} but I get this error: CuArray only supports element types that are stored inline I don’t understand what i…

---

## [Unrolling of loops with operations on CuArrays](https://discourse.julialang.org/t/unrolling-of-loops-with-operations-on-cuarrays/70468)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 4\
**Last updated:** [October 27, 2021, 5:10pm UTC](https://discourse.julialang.org/t/unrolling-of-loops-with-operations-on-cuarrays/70468 "2021-10-27T17:10:42Z")

</div>

I have a loop where at each iteration I do some vectorial operation over CuArray. For example using CUDA N = 4 a = ones(N) u = CUDA.zeros(1000) @. u = a\[1\] for i=2:N @. u += a\[i\] end As far as I understand, in t…

---

## [Error This intrinsic must be compiled to be called. Flux/Zygote](https://discourse.julialang.org/t/error-this-intrinsic-must-be-compiled-to-be-called-flux-zygote/66966)

<div class="topic-metadata">

**Author:** [@bgladman](https://discourse.julialang.org/u/bgladman)\
**Replies:** 5\
**Last updated:** [August 28, 2021, 1:10am UTC](https://discourse.julialang.org/t/error-this-intrinsic-must-be-compiled-to-be-called-flux-zygote/66966 "2021-08-28T01:10:33Z")

</div>

Hey all. I am trying to implement a neural network controller which emulates this example https://github.com/FluxML/Trebuchet.jl. In place of the ODE solver I am using a previously trained Flux model which outputs a si…

---

## [Converting - for loop to Cuarray dot syntax](https://discourse.julialang.org/t/converting-for-loop-to-cuarray-dot-syntax/55679)

<div class="topic-metadata">

**Author:** [@naviinkapoor](https://discourse.julialang.org/u/naviinkapoor)\
**Replies:** 8\
**Last updated:** [February 20, 2021, 3:59pm UTC](https://discourse.julialang.org/t/converting-for-loop-to-cuarray-dot-syntax/55679 "2021-02-20T15:59:37Z")

</div>

Hello Everyone, I need help to convert the below code to carry dot syntax From for i=1:j a\[i\] = a\[i\] + a\[i+j\] end I converted it to a\[1:j\].=a\[1:j\].+a\[1:j+j\] , but it is not working

---

## [ERROR: this intrinsic must be compiled to be called](https://discourse.julialang.org/t/error-this-intrinsic-must-be-compiled-to-be-called/52497)

<div class="topic-metadata">

**Author:** [@kadir-gunel](https://discourse.julialang.org/u/kadir-gunel)\
**Replies:** 9\
**Last updated:** [December 29, 2020, 6:00am UTC](https://discourse.julialang.org/t/error-this-intrinsic-must-be-compiled-to-be-called/52497 "2020-12-29T06:00:01Z")

</div>

Hello, For the past 2 weeks , I have been struggling with a flux model that I wrote. Since I am newbie to flux, zygote, and CuArrays, certainly, I don’t understand what is the actual problem right away. Below, I leave a…

---

## [Efficient and CuArray compatible implementation of \`StatsBase.\_compute\_extrema\`](https://discourse.julialang.org/t/efficient-and-cuarray-compatible-implementation-of-statsbase-compute-extrema/51671)

<div class="topic-metadata">

**Author:** [@sdewaele](https://discourse.julialang.org/u/sdewaele)\
**Replies:** 5\
**Last updated:** [December 17, 2020, 8:25pm UTC](https://discourse.julialang.org/t/efficient-and-cuarray-compatible-implementation-of-statsbase-compute-extrema/51671 "2020-12-17T20:25:10Z")

</div>

For this PR to StatsBase.jl, I am looking for a way to compute extrema that is both efficient for regular arrays and CuArrays. This implementation is efficient for regular arrays: function \_compute\_extrema\_A(X; dims) …

---

## [CuArrays Question (cannot take the CPU address of a CuArray{Float32,2,Nothing})](https://discourse.julialang.org/t/cuarrays-question-cannot-take-the-cpu-address-of-a-cuarray-float32-2-nothing/42560)

<div class="topic-metadata">

**Author:** [@jmurray](https://discourse.julialang.org/u/jmurray)\
**Replies:** 2\
**Last updated:** [October 20, 2020, 11:53pm UTC](https://discourse.julialang.org/t/cuarrays-question-cannot-take-the-cpu-address-of-a-cuarray-float32-2-nothing/42560 "2020-10-20T23:53:32Z")

</div>

I’m new to CuArrays and there’s something I’m not quite understanding. I have a working example that pipes the data and the model to the GPU and trains there. But when I try to call the loss function outside of the train…

---

## [CUDA Error in constant CuArray with conditional usage](https://discourse.julialang.org/t/cuda-error-in-constant-cuarray-with-conditional-usage/48581)

<div class="topic-metadata">

**Author:** [@ozmaden](https://discourse.julialang.org/u/ozmaden)\
**Replies:** 3\
**Last updated:** [October 19, 2020, 10:37pm UTC](https://discourse.julialang.org/t/cuda-error-in-constant-cuarray-with-conditional-usage/48581 "2020-10-19T22:37:12Z")

</div>

Hi everyone, I am confronted with an error concerning a constant CuArray. Any help would be greatly appreciated. Quick context: I’m one of the developers of the GNSSSignals package, adapting it to do signal processing …

---

## [Mapping functions using CuArrays](https://discourse.julialang.org/t/mapping-functions-using-cuarrays/46300)

<div class="topic-metadata">

**Author:** [@manderson](https://discourse.julialang.org/u/manderson)\
**Replies:** 2\
**Last updated:** [September 9, 2020, 4:12pm UTC](https://discourse.julialang.org/t/mapping-functions-using-cuarrays/46300 "2020-09-09T16:12:00Z")

</div>

I am attempting to map functions to the GPU using CUDA, CuArrays, and map(). My ultimate goal is to take what is currently a serial grid search and run each reduction in parallel on the GPU. For this, I need to pass a v…

---

## [Column-wise reduction on a CUDA.CuArray matrix](https://discourse.julialang.org/t/column-wise-reduction-on-a-cuda-cuarray-matrix/45069)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 0\
**Last updated:** [August 16, 2020, 10:33pm UTC](https://discourse.julialang.org/t/column-wise-reduction-on-a-cuda-cuarray-matrix/45069 "2020-08-16T22:33:44Z")

</div>

As suggested here, I am trying to create a version of this findfirst kernel that operates over dimension 2 of input matrix xs and returns the first match for each vector along dimension 1. I think a good approach is a c…

---

## [Help Debugging GPU Performance Issue](https://discourse.julialang.org/t/help-debugging-gpu-performance-issue/42274)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 5\
**Last updated:** [July 1, 2020, 10:07am UTC](https://discourse.julialang.org/t/help-debugging-gpu-performance-issue/42274 "2020-07-01T10:07:43Z")

</div>

I’m having trouble debugging the following issue with CuArrays. I see very different performance using the findmax function when I call it from the REPL vs when I use it in my application. From the REPL I get the desired…

---

## [CUDNNError when using Flux within a Task](https://discourse.julialang.org/t/cudnnerror-when-using-flux-within-a-task/39199)

<div class="topic-metadata">

**Author:** [@jonathan-laurent](https://discourse.julialang.org/u/jonathan-laurent)\
**Replies:** 15\
**Last updated:** [June 22, 2020, 5:33pm UTC](https://discourse.julialang.org/t/cudnnerror-when-using-flux-within-a-task/39199 "2020-06-22T17:33:40Z")

</div>

I have been trying to release a Flux backend for my AlphaZero.jl library, but I am encountering a mysterious CUDNN error (CUDNN\_STATUS\_INTERNAL\_ERROR). Here is some info: The error happens consistently at every run, a…

---

## [Complex vector math performance: StructArray of CuArrays vs CuArrays](https://discourse.julialang.org/t/complex-vector-math-performance-structarray-of-cuarrays-vs-cuarrays/40576)

<div class="topic-metadata">

**Author:** [@ozmaden](https://discourse.julialang.org/u/ozmaden)\
**Replies:** 2\
**Last updated:** [June 22, 2020, 4:40pm UTC](https://discourse.julialang.org/t/complex-vector-math-performance-structarray-of-cuarrays-vs-cuarrays/40576 "2020-06-22T16:40:45Z")

</div>

Hi there! I’m benchmarking a GPU implementation of a function performing downconversion of a signal given a carrier signal replica. The original form of the function in the library looks like this: julia\> function downc…

---

## [Split an array into multiple smaller arrays - alternative to unsafe\_wrap without views](https://discourse.julialang.org/t/split-an-array-into-multiple-smaller-arrays-alternative-to-unsafe-wrap-without-views/39150)

<div class="topic-metadata">

**Author:** [@clinton](https://discourse.julialang.org/u/clinton)\
**Replies:** 0\
**Last updated:** [May 8, 2020, 11:58pm UTC](https://discourse.julialang.org/t/split-an-array-into-multiple-smaller-arrays-alternative-to-unsafe-wrap-without-views/39150 "2020-05-08T23:58:48Z")

</div>

I’m wondering if this is a good use case for unsafe\_wrap, or if there is a better way to do this. Basically I have a vector, and I want to be able to interpret the vector as a set of arrays. I cannot use subarrays or sim…

---

## [How to convert an array to a CuArray efficiently](https://discourse.julialang.org/t/how-to-convert-an-array-to-a-cuarray-efficiently/38612)

<div class="topic-metadata">

**Author:** [@Dustin\_Hess](https://discourse.julialang.org/u/Dustin_Hess)\
**Replies:** 3\
**Last updated:** [May 2, 2020, 11:26pm UTC](https://discourse.julialang.org/t/how-to-convert-an-array-to-a-cuarray-efficiently/38612 "2020-05-02T23:26:40Z")

</div>

Please forgive me as I am taking my first step in using GPU’s in Julia. My use case is I want to do some processioning of electron microscope image stacks from a TEM. So I have everything setup and I have some micrograph…

---

## [Training Halts when Using CuArrarys](https://discourse.julialang.org/t/training-halts-when-using-cuarrarys/38062)

<div class="topic-metadata">

**Author:** [@lpjiang97](https://discourse.julialang.org/u/lpjiang97)\
**Replies:** 0\
**Last updated:** [April 23, 2020, 4:40am UTC](https://discourse.julialang.org/t/training-halts-when-using-cuarrarys/38062 "2020-04-23T04:40:35Z")

</div>

(open issue here) I’m fairly new to CuArrays and Flux, and I met this problem of having halted training after some epochs. There is no CUDA out of memory error, but the usage is extremely high for this simple linear mod…

---

## [Use GPU subfunction in a bigger-function?](https://discourse.julialang.org/t/use-gpu-subfunction-in-a-bigger-function/37768)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 5\
**Last updated:** [April 19, 2020, 6:18pm UTC](https://discourse.julialang.org/t/use-gpu-subfunction-in-a-bigger-function/37768 "2020-04-19T18:18:59Z")

</div>

Hello! My question title is properly worded poorly, but here goes. I have made a “subfunction”, called gpu\_ParticlePackStep! which calculates properties for one particle. If I call this function as such in Julia: gpu\_P…

---

## [CuArrays v2.0.1 results in segmentation fault for LinearAlgebra.mul!](https://discourse.julialang.org/t/cuarrays-v2-0-1-results-in-segmentation-fault-for-linearalgebra-mul/36755)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 4\
**Last updated:** [March 31, 2020, 7:56am UTC](https://discourse.julialang.org/t/cuarrays-v2-0-1-results-in-segmentation-fault-for-linearalgebra-mul/36755 "2020-03-31T07:56:51Z")

</div>

The following code with CuArrays v2.0.1 results in segmentation fault on my computer: import CuArrays import LinearAlgebra N = 1024 y = CuArrays.zeros(N) x = CuArrays.zeros(N) A = CuArrays.zeros((N, N)) LinearAlgebra…

---

## [Type inconsistency for sum function in case of complex CuArrays](https://discourse.julialang.org/t/type-inconsistency-for-sum-function-in-case-of-complex-cuarrays/36540)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 0\
**Last updated:** [March 26, 2020, 7:57am UTC](https://discourse.julialang.org/t/type-inconsistency-for-sum-function-in-case-of-complex-cuarrays/36540 "2020-03-26T07:57:21Z")

</div>

The result of sum(abs2, a) for complex a is also complex in case of a being a CuArray: using CuArrays a = zeros(ComplexF32, 10) s = sum(abs2, a) @show typeof(s) agpu = CuArrays.zeros(ComplexF32, 10) sgpu = sum(abs2, a…

[Next page](https://discourse.julialang.org/tag/cuarrays/361.md?match_all_tags=true&page=1&tags%5B%5D=cuarrays)
