# GPU

**URL:** https://discourse.julialang.org/c/domain/gpu/11.md?page=11

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

**Page:** 12

---

## [CUDA on JuliaHub](https://discourse.julialang.org/t/cuda-on-juliahub/99028)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 4\
**Last updated:** [July 10, 2023, 6:36am UTC](https://discourse.julialang.org/t/cuda-on-juliahub/99028 "2023-07-10T06:36:43Z")

</div>

Using CUDA on JuliaHub gives the error julia\> using CUDA \[ Info: Precompiling CUDA \[052768ef-5323-5732-b1bb-66c8b64840ba\] ┌ Error: JULIA\_CUDA\_VERSION is deprecated. Call \`CUDA.jl.set\_runtime\_version!\` to use a differen…

---

## [Suggestion: NVIDIA RTX 3070 Ti (8GB) or RTX 4090 (16 GB)?](https://discourse.julialang.org/t/suggestion-nvidia-rtx-3070-ti-8gb-or-rtx-4090-16-gb/101121)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 15\
**Last updated:** [July 4, 2023, 11:25am UTC](https://discourse.julialang.org/t/suggestion-nvidia-rtx-3070-ti-8gb-or-rtx-4090-16-gb/101121 "2023-07-04T11:25:01Z")

</div>

Hello, I have never worked with GPU and it’s time to change our server, so… :slight\_smile: Which would be a entry-level NVIDIA GPU suitable to work with neural network operations / Flux ? I mean something that would st…

---

## [GPU generalized eigendecomposition](https://discourse.julialang.org/t/gpu-generalized-eigendecomposition/101042)

<div class="topic-metadata">

**Author:** [@smartalecH](https://discourse.julialang.org/u/smartalecH)\
**Replies:** 1\
**Last updated:** [July 1, 2023, 8:48pm UTC](https://discourse.julialang.org/t/gpu-generalized-eigendecomposition/101042 "2023-07-01T20:48:48Z")

</div>

I’d like to perform a generalized eigendecomp on my (CUDA-enabled) GPU. My matrix is dense, complex, and non-hermitian. I’d like the full decomposition (all the eigenvectors), not just a targeted eigensolve. I know tha…

---

## [Disable all GPU support when using Lux](https://discourse.julialang.org/t/disable-all-gpu-support-when-using-lux/100076)

<div class="topic-metadata">

**Author:** [@contradict](https://discourse.julialang.org/u/contradict)\
**Replies:** 5\
**Last updated:** [July 2, 2023, 2:26am UTC](https://discourse.julialang.org/t/disable-all-gpu-support-when-using-lux/100076 "2023-07-02T02:26:26Z")

</div>

I have an old GPU which is no longer supported and would like to run Lux anyway using just the CPU. $ nvidia-smi -L GPU 0: NVIDIA GeForce GTX 680 (UUID: GPU-49fc79e3-b888-22fe-dc46-f3233d654e1b) I tried the suggestion …

---

## [Using real NCHW order when using cuDNN.jl](https://discourse.julialang.org/t/using-real-nchw-order-when-using-cudnn-jl/100842)

<div class="topic-metadata">

**Author:** [@Jonas208](https://discourse.julialang.org/u/Jonas208)\
**Replies:** 4\
**Last updated:** [June 30, 2023, 9:39pm UTC](https://discourse.julialang.org/t/using-real-nchw-order-when-using-cudnn-jl/100842 "2023-06-30T21:39:31Z")

</div>

I am trying to use cuDNN.jl for GPU accelerated convolution. I used the function cuDNN.cudnnConvolutionForward. The function has the keyword argument format that specifies the order of dimensions (format=cuDNN.CUDNN\_TEN…

---

## [Scatter/gather operation with Metal](https://discourse.julialang.org/t/scatter-gather-operation-with-metal/100971)

<div class="topic-metadata">

**Author:** [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Replies:** 1\
**Last updated:** [June 30, 2023, 6:10am UTC](https://discourse.julialang.org/t/scatter-gather-operation-with-metal/100971 "2023-06-30T06:10:24Z")

</div>

Hey everyone. I would like to convert the following scatter/gather operation from the CPU to the GPU, using Metal.jl. function gather!(y::AbstractVector, refs::AbstractVector, x::AbstractVector) for i in eachindex(y…

---

## [Vectorize function for two same size CuArray](https://discourse.julialang.org/t/vectorize-function-for-two-same-size-cuarray/100983)

<div class="topic-metadata">

**Author:** [@kuanchiun](https://discourse.julialang.org/u/kuanchiun)\
**Replies:** 2\
**Last updated:** [June 30, 2023, 6:06am UTC](https://discourse.julialang.org/t/vectorize-function-for-two-same-size-cuarray/100983 "2023-06-30T06:06:36Z")

</div>

Hello! I’m rookie for Julia programming language. I’m trying to create the loss function, which calculate cosine similarity for each row pair in x, x̂. The simply code is in below. using Flux, CUDA, LinearAlgebra CUDA…

---

## [Program has different results when ran in REPL and from Nsight compute](https://discourse.julialang.org/t/program-has-different-results-when-ran-in-repl-and-from-nsight-compute/100817)

<div class="topic-metadata">

**Author:** [@Zentrik](https://discourse.julialang.org/u/Zentrik)\
**Replies:** 1\
**Last updated:** [June 25, 2023, 7:03pm UTC](https://discourse.julialang.org/t/program-has-different-results-when-ran-in-repl-and-from-nsight-compute/100817 "2023-06-25T19:03:17Z")

</div>

index = CuArray{UInt32}(\[1\]) function ker(index) i = (blockIdx().x - Int32(1)) \* blockDim().x + threadIdx().x @cuprintln "i: " i @cuprintln "index: " index\[\] @cuprintln "old\_index: " index\[\] += 1 ret…

---

## [Using an Intel GPU on Macbook Pro](https://discourse.julialang.org/t/using-an-intel-gpu-on-macbook-pro/100782)

<div class="topic-metadata">

**Author:** [@alexdmeyer](https://discourse.julialang.org/u/alexdmeyer)\
**Replies:** 6\
**Last updated:** [June 25, 2023, 8:59am UTC](https://discourse.julialang.org/t/using-an-intel-gpu-on-macbook-pro/100782 "2023-06-25T08:59:46Z")

</div>

Hey Julia Community, I’m only just starting to learn about GPU programming (mainly for deep learning with Flux, but I’m curious if/how I could use it for my other projects). One barrier to getting started, though, is I…

---

## [Asynchronous kernel scheduling with KernelAbstractions](https://discourse.julialang.org/t/asynchronous-kernel-scheduling-with-kernelabstractions/100535)

<div class="topic-metadata">

**Author:** [@smartalecH](https://discourse.julialang.org/u/smartalecH)\
**Replies:** 5\
**Last updated:** [June 25, 2023, 4:53am UTC](https://discourse.julialang.org/t/asynchronous-kernel-scheduling-with-kernelabstractions/100535 "2023-06-25T04:53:21Z")

</div>

The KernelAbstractions docs mention that kernels are launched asynchronously. I’m hoping to leverage this within a solver I’m working on, where I hope to hide the communication between GPUs behind some computation (a com…

---

## [How to do mapslices() in parallel for 3D arrays](https://discourse.julialang.org/t/how-to-do-mapslices-in-parallel-for-3d-arrays/100484)

<div class="topic-metadata">

**Author:** [@huiyuxie](https://discourse.julialang.org/u/huiyuxie)\
**Replies:** 2\
**Last updated:** [June 24, 2023, 7:00am UTC](https://discourse.julialang.org/t/how-to-do-mapslices-in-parallel-for-3d-arrays/100484 "2023-06-24T07:00:49Z")

</div>

Basically I am going to transform mapslices() using kernels. This function slices each layer from a 3D array and multiplies each layer by the same matrix, like below A = rand(4, 4, 3) B = rand(4, 4) C = similar(A) C = …

---

## [Possible reordering of floating point arithmetic in CUDA.jl](https://discourse.julialang.org/t/possible-reordering-of-floating-point-arithmetic-in-cuda-jl/100692)

<div class="topic-metadata">

**Author:** [@loonatick-src](https://discourse.julialang.org/u/loonatick-src)\
**Replies:** 3\
**Last updated:** [June 22, 2023, 3:25pm UTC](https://discourse.julialang.org/t/possible-reordering-of-floating-point-arithmetic-in-cuda-jl/100692 "2023-06-22T15:25:23Z")

</div>

(Also posted on SO) I have a very simple kernel. function kernel!(u, r, β::Number) u .= u .\* β .+ r end Clearly, it is embarrassingly parallel. I execute in on both the CPU and the GPU like so. (You might have to…

---

## [Error when using CUDA.dot() in kernel](https://discourse.julialang.org/t/error-when-using-cuda-dot-in-kernel/100476)

<div class="topic-metadata">

**Author:** [@huiyuxie](https://discourse.julialang.org/u/huiyuxie)\
**Replies:** 2\
**Last updated:** [June 18, 2023, 5:13am UTC](https://discourse.julialang.org/t/error-when-using-cuda-dot-in-kernel/100476 "2023-06-18T05:13:27Z")

</div>

Here is a very simple version of trying to compute dot product in GPU kernel. Having tried c\[i\] = transpose(a\[i, :\]) \* b\[:, i\] c\[i\] = CUDA.dot(a\[i, :\], b\[:, i\]) c\[i\] = CUBLAS.dot(4, a\[i, :\], b\[:, i\]) but all reported…

---

## [Sampling from a probability distribution on GPU](https://discourse.julialang.org/t/sampling-from-a-probability-distribution-on-gpu/94389)

<div class="topic-metadata">

**Author:** [@ArjunNarayanan](https://discourse.julialang.org/u/ArjunNarayanan)\
**Replies:** 13\
**Last updated:** [June 13, 2023, 12:52pm UTC](https://discourse.julialang.org/t/sampling-from-a-probability-distribution-on-gpu/94389 "2023-06-13T12:52:00Z")

</div>

I’m interested in doing something like using Distributions: Categorical using CUDA p = cu(\[0.7,0.2,0.1\]) idx = rand(Categorical(p)) Is there a way to sample from a vector of probability masses on the GPU? This kind of…

---

## [Simple Enzyme AD on CUDA GPU](https://discourse.julialang.org/t/simple-enzyme-ad-on-cuda-gpu/99966)

<div class="topic-metadata">

**Author:** [@Thaegy](https://discourse.julialang.org/u/Thaegy)\
**Replies:** 5\
**Last updated:** [June 9, 2023, 11:00pm UTC](https://discourse.julialang.org/t/simple-enzyme-ad-on-cuda-gpu/99966 "2023-06-09T23:00:08Z")

</div>

Hi there, I have just started thinking about moving some of my JAX code to Julia and wanted to have a go using Enzyme for my AD. I am looking to make use of CUDA GPUs. I have started with a simple program to verify thin…

---

## [Laguerre polynomials on GPU](https://discourse.julialang.org/t/laguerre-polynomials-on-gpu/99571)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 27\
**Last updated:** [June 9, 2023, 11:35am UTC](https://discourse.julialang.org/t/laguerre-polynomials-on-gpu/99571 "2023-06-09T11:35:19Z")

</div>

Hello, I’m currently able to calculate the generalized Laguerre polynomials on the CPU using HypergeometricFunctions \_genlaguerre(n, α, x) = binomial(n+α,n) \* HypergeometricFunctions.M(-n, α+1, x) A = rand(1000, 1000)…

---

## [An optimization problem on GPU works in Julia v1.8, but does not work in v1.9](https://discourse.julialang.org/t/an-optimization-problem-on-gpu-works-in-julia-v1-8-but-does-not-work-in-v1-9/100036)

<div class="topic-metadata">

**Author:** [@DennisFang](https://discourse.julialang.org/u/DennisFang)\
**Replies:** 2\
**Last updated:** [June 9, 2023, 4:19am UTC](https://discourse.julialang.org/t/an-optimization-problem-on-gpu-works-in-julia-v1-8-but-does-not-work-in-v1-9/100036 "2023-06-09T04:19:47Z")

</div>

Hello, I’m doing an optimization problem and trying to work on CUDA. I can run my program in Julia v1.8.2 and v1.8.5. However, I get some errors when running on the GPU in Julia v1.9.0 and v1.9.1. Here is a minimum exa…

---

## [GPU: Scalar indexing in kernel programming](https://discourse.julialang.org/t/gpu-scalar-indexing-in-kernel-programming/99878)

<div class="topic-metadata">

**Author:** [@yuwenchen95](https://discourse.julialang.org/u/yuwenchen95)\
**Replies:** 2\
**Last updated:** [June 5, 2023, 12:36pm UTC](https://discourse.julialang.org/t/gpu-scalar-indexing-in-kernel-programming/99878 "2023-06-05T12:36:12Z")

</div>

Hi all, I have a vector x of dim m\*n and want to parallel an operation over each slice of length m. For example, x\_{1:m} corresponds to a value -log(x\[1\]^2 - sum\_{i=2}^m x\[i\]^2) as shown in the function compute\_barrier!…

---

## [Illegal memory indexing for broadcast of a recursive function](https://discourse.julialang.org/t/illegal-memory-indexing-for-broadcast-of-a-recursive-function/99534)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 6\
**Last updated:** [May 31, 2023, 7:20am UTC](https://discourse.julialang.org/t/illegal-memory-indexing-for-broadcast-of-a-recursive-function/99534 "2023-05-31T07:20:16Z")

</div>

Hello, I’m trying to implement the generalized Laguerre function acting element-wise to the elements of a CuArray. The basic code uses a recursive function to evaluate the laguerre polynomial using CUDA using LinearAl…

---

## [Unsafe\_convert when trying to run a neural network on GPU](https://discourse.julialang.org/t/unsafe-convert-when-trying-to-run-a-neural-network-on-gpu/99396)

<div class="topic-metadata">

**Author:** [@jarroyoe](https://discourse.julialang.org/u/jarroyoe)\
**Replies:** 4\
**Last updated:** [May 27, 2023, 1:22pm UTC](https://discourse.julialang.org/t/unsafe-convert-when-trying-to-run-a-neural-network-on-gpu/99396 "2023-05-27T13:22:17Z")

</div>

I want to run a single input neural network using CUDA as follows. using CUDA, Lux, Random rng = Random.default\_rng() data = gpu(rand(3,10)) neuralNetwork = Lux.Chain(Lux.Dense(1,4),Lux.Dense(4,2)) ps,st = Lux.setup(rn…

---

## [Error when running DiffEqGPU example from documentation](https://discourse.julialang.org/t/error-when-running-diffeqgpu-example-from-documentation/99405)

<div class="topic-metadata">

**Author:** [@jogama](https://discourse.julialang.org/u/jogama)\
**Replies:** 2\
**Last updated:** [May 26, 2023, 1:06pm UTC](https://discourse.julialang.org/t/error-when-running-diffeqgpu-example-from-documentation/99405 "2023-05-26T13:06:30Z")

</div>

Hello, I ran the following example, copy-pasted from here, and received an UndefVarError. Here is the example snippet from the linked website: using DiffEqGPU, OrdinaryDiffEq function lorenz(du, u, p, t) du\[1\] = p…

---

## [DiffEq documentation example slower on GPU (33 sec) than on CPU (0.14 sec)](https://discourse.julialang.org/t/diffeq-documentation-example-slower-on-gpu-33-sec-than-on-cpu-0-14-sec/99407)

<div class="topic-metadata">

**Author:** [@jogama](https://discourse.julialang.org/u/jogama)\
**Replies:** 4\
**Last updated:** [May 25, 2023, 10:41pm UTC](https://discourse.julialang.org/t/diffeq-documentation-example-slower-on-gpu-33-sec-than-on-cpu-0-14-sec/99407 "2023-05-25T22:41:31Z")

</div>

Hello, We were surprized to see that example code on the online documentation ran slower on the GPU than on the CPU. https://docs.sciml.ai/DiffEqGPU/stable/getting\_started/#Simple-Example-of-Within-Method-GPU-Paralleli…

---

## [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…

---

## [DiffEqFlux throws a CUDA error on installation](https://discourse.julialang.org/t/diffeqflux-throws-a-cuda-error-on-installation/99212)

<div class="topic-metadata">

**Author:** [@Vidianos](https://discourse.julialang.org/u/Vidianos)\
**Replies:** 6\
**Last updated:** [May 22, 2023, 6:52pm UTC](https://discourse.julialang.org/t/diffeqflux-throws-a-cuda-error-on-installation/99212 "2023-05-22T18:52:18Z")

</div>

Hello, I am trying to get into the SciML ecosystem and as such I installed DiffEqFlux. During installation, I get this error Blockquote DiffEqFlux \[aae7a2af-3d4f-5e19-a356-7da93b79d9d0\] │ ┌ Error: Failed to initial…

---

## [Is CUDA.jl and FFTW threadsafe?](https://discourse.julialang.org/t/is-cuda-jl-and-fftw-threadsafe/99219)

<div class="topic-metadata">

**Author:** [@jpdoane](https://discourse.julialang.org/u/jpdoane)\
**Replies:** 4\
**Last updated:** [May 22, 2023, 2:44pm UTC](https://discourse.julialang.org/t/is-cuda-jl-and-fftw-threadsafe/99219 "2023-05-22T14:44:21Z")

</div>

I am getting the following error when using CUDA.jl FFTW plans in multiple threads. Is this interface not threadsafe? If not, do I just need a mutex around plan\_fft!(), or might the actual fft be not threadsafe as well? …

---

## [Error During Test in wmma.jl](https://discourse.julialang.org/t/error-during-test-in-wmma-jl/99035)

<div class="topic-metadata">

**Author:** [@huiyuxie](https://discourse.julialang.org/u/huiyuxie)\
**Replies:** 2\
**Last updated:** [May 19, 2023, 8:11pm UTC](https://discourse.julialang.org/t/error-during-test-in-wmma-jl/99035 "2023-05-19T20:11:10Z")

</div>

Hi! I run test CUDA to ensure that everything works as expected. But some errors occurred as below. Are these errors related to the test file or the configuration of the system? How can I resolve them? Thanks! I have…

---

## [Help with AutoDiff in Metal.jl](https://discourse.julialang.org/t/help-with-autodiff-in-metal-jl/98937)

<div class="topic-metadata">

**Author:** [@raktim](https://discourse.julialang.org/u/raktim)\
**Replies:** 7\
**Last updated:** [May 17, 2023, 5:54am UTC](https://discourse.julialang.org/t/help-with-autodiff-in-metal-jl/98937 "2023-05-17T05:54:58Z")

</div>

I am trying to use Metal.jl for a scientific computation and having difficulty with AutoDiff (ForwardDiff). I am using julia 1.9. This is the code dF = x-\>ForwardDiff.gradient(x-\>dot(x,x),x) N = 7; x = rand(Float32,N);…

---

## [Why is GPU kernel rand() not as "random" as CPU rand()?](https://discourse.julialang.org/t/why-is-gpu-kernel-rand-not-as-random-as-cpu-rand/98892)

<div class="topic-metadata">

**Author:** [@ReWoP](https://discourse.julialang.org/u/ReWoP)\
**Replies:** 10\
**Last updated:** [May 17, 2023, 2:41am UTC](https://discourse.julialang.org/t/why-is-gpu-kernel-rand-not-as-random-as-cpu-rand/98892 "2023-05-17T02:41:53Z")

</div>

Hi all, I’m implementing some optimization algorithms in the GPU (CUDA) that rely on, among other things, random numbers to set the exploration of the search space. I’m also comparing the results with the CPU implementa…

---

## [Fast ways of updating a \`CuArray\` along certain diagonals based on results from CPU](https://discourse.julialang.org/t/fast-ways-of-updating-a-cuarray-along-certain-diagonals-based-on-results-from-cpu/98910)

<div class="topic-metadata">

**Author:** [@Norman](https://discourse.julialang.org/u/Norman)\
**Replies:** 0\
**Last updated:** [May 16, 2023, 6:11am UTC](https://discourse.julialang.org/t/fast-ways-of-updating-a-cuarray-along-certain-diagonals-based-on-results-from-cpu/98910 "2023-05-16T06:11:03Z")

</div>

I have a scenario in which I need to repetitively updating a CuArray along certain diagonals based on results computed from CPU. The number of diagonals involved can be small and may change across different problems (typ…

---

## [Help with Custom Struct for High Dimensional COO Arrays](https://discourse.julialang.org/t/help-with-custom-struct-for-high-dimensional-coo-arrays/98934)

<div class="topic-metadata">

**Author:** [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Replies:** 1\
**Last updated:** [May 16, 2023, 2:57pm UTC](https://discourse.julialang.org/t/help-with-custom-struct-for-high-dimensional-coo-arrays/98934 "2023-05-16T14:57:14Z")

</div>

Hello, I have an application where I need \>2 dimensional sparse arrays and I would like to test running them on the GPU as the application is embarrassingly parallel. My plan was to make a CuArray of the type TensorVal …

[Previous page](https://discourse.julialang.org/c/domain/gpu/11.md?page=10)

[Next page](https://discourse.julialang.org/c/domain/gpu/11.md?page=12)
