# GPU

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

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

**Page:** 32

---

## [Initializing Sparse Matrices with CuArrays.jl](https://discourse.julialang.org/t/initializing-sparse-matrices-with-cuarrays-jl/21062)

<div class="topic-metadata">

**Author:** [@carlomontec](https://discourse.julialang.org/u/carlomontec)\
**Replies:** 4\
**Last updated:** [February 22, 2019, 7:05am UTC](https://discourse.julialang.org/t/initializing-sparse-matrices-with-cuarrays-jl/21062 "2019-02-22T07:05:41Z")

</div>

Hello, total newbie with GPU computing here. I have seen that is possible to use sparse matrices with CuArrays.jl, but I have not found a way to initialize them. I tried to with the example described at https://github.…

---

## [Best way to store data for GPU use](https://discourse.julialang.org/t/best-way-to-store-data-for-gpu-use/20792)

<div class="topic-metadata">

**Author:** [@MrRobot](https://discourse.julialang.org/u/MrRobot)\
**Replies:** 7\
**Last updated:** [February 16, 2019, 5:27pm UTC](https://discourse.julialang.org/t/best-way-to-store-data-for-gpu-use/20792 "2019-02-16T17:27:14Z")

</div>

Hello, I am writing code in Julia for molecular simulation. Currently it is only for CPU’s, but I would like to convert it to GPU’s once I have it running and tested. I am forever in a quandary about how to store data (…

---

## [GPU Map without reduction on multiple arrays indices](https://discourse.julialang.org/t/gpu-map-without-reduction-on-multiple-arrays-indices/20565)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 1\
**Last updated:** [February 8, 2019, 7:20am UTC](https://discourse.julialang.org/t/gpu-map-without-reduction-on-multiple-arrays-indices/20565 "2019-02-08T07:20:11Z")

</div>

Hello, I would like to compute a multi-dimensional array (4-D) A of a 2 components function f on a large multi-dimensional domain (X,Y,T) with GPU. So A will have size: 2, NX, NY, NT. X, Y and T are 1D arrays I tried …

---

## [Slow first run inside functions](https://discourse.julialang.org/t/slow-first-run-inside-functions/19638)

<div class="topic-metadata">

**Author:** [@sw2030](https://discourse.julialang.org/u/sw2030)\
**Replies:** 5\
**Last updated:** [February 4, 2019, 12:22pm UTC](https://discourse.julialang.org/t/slow-first-run-inside-functions/19638 "2019-02-04T12:22:10Z")

</div>

Hello, It seems like the first run of norm(not only norm but also other functions) inside function is slower than the second run even after the first time compilation. This is even worse(100x times) in case of heavier f…

---

## [GPU sort WIP (GPU 1000x faster than CPU? I must be doing something wrong)](https://discourse.julialang.org/t/gpu-sort-wip-gpu-1000x-faster-than-cpu-i-must-be-doing-something-wrong/20310)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 12\
**Last updated:** [January 31, 2019, 8:46pm UTC](https://discourse.julialang.org/t/gpu-sort-wip-gpu-1000x-faster-than-cpu-i-must-be-doing-something-wrong/20310 "2019-01-31T20:46:10Z")

</div>

I am working on a GPU sort using CUDAnative and CuArrays. This is my generic bitonic sort (can only sort arrays of size 2^N elements for now). I am sorting 2^26=67\_108\_864 Float32s using the optimised Radixsort (CPU) vs…

---

## [Most efficient way of \_waiting\_ for GPU results?](https://discourse.julialang.org/t/most-efficient-way-of-waiting-for-gpu-results/19193)

<div class="topic-metadata">

**Author:** [@anj](https://discourse.julialang.org/u/anj)\
**Replies:** 20\
**Last updated:** [January 31, 2019, 7:25pm UTC](https://discourse.julialang.org/t/most-efficient-way-of-waiting-for-gpu-results/19193 "2019-01-31T19:25:11Z")

</div>

Hello, I am using the following pattern today to synchronize results of the GPU processing back to CPU (CUDAnative, CuArrays, CUDAdrv) # data\_out\_gpu and data\_in\_gpu are CuArrays #do\_some\_gpu\_processing() will launch k…

---

## [CuArray/CUDAnative argmin paradoxical performance](https://discourse.julialang.org/t/cuarray-cudanative-argmin-paradoxical-performance/20194)

<div class="topic-metadata">

**Author:** [@Alex\_Ellison](https://discourse.julialang.org/u/Alex_Ellison)\
**Replies:** 2\
**Last updated:** [January 31, 2019, 5:35pm UTC](https://discourse.julialang.org/t/cuarray-cudanative-argmin-paradoxical-performance/20194 "2019-01-31T17:35:10Z")

</div>

Hey there, I have a kernel which computes some 3D CuArray of float32s, and I’d like to run argmin on one of the axes, resulting in a 2D set of indices. For some reason, if I invoke CUDAnative.argmin on the original host…

---

## [Generic CPU and GPU loops with tiled iteration](https://discourse.julialang.org/t/generic-cpu-and-gpu-loops-with-tiled-iteration/20295)

<div class="topic-metadata">

**Author:** [@datnamer](https://discourse.julialang.org/u/datnamer)\
**Replies:** 3\
**Last updated:** [January 31, 2019, 3:55am UTC](https://discourse.julialang.org/t/generic-cpu-and-gpu-loops-with-tiled-iteration/20295 "2019-01-31T03:55:11Z")

</div>

Can Tilediteration be used to write loops that work on GPU and CPUs without having to have separate kernels for the latter or stuff everything into broadcast(s)? @tim.holy

---

## [Writing fast stencil computation kernels that work on both CPUs and GPUs](https://discourse.julialang.org/t/writing-fast-stencil-computation-kernels-that-work-on-both-cpus-and-gpus/20200)

<div class="topic-metadata">

**Author:** [@PolarizedPoutine](https://discourse.julialang.org/u/PolarizedPoutine)\
**Replies:** 3\
**Last updated:** [January 29, 2019, 2:04pm UTC](https://discourse.julialang.org/t/writing-fast-stencil-computation-kernels-that-work-on-both-cpus-and-gpus/20200 "2019-01-29T14:04:13Z")

</div>

Hi everyone, I am developing a 3D finite volume ocean model in Julia (Oceananigans.jl). For now I have the model running reasonably fast on a CPU and I’m trying to get it to run efficiently on a GPU using CUDAnative and…

---

## [\`sync\_threads()\` doesn't seem to work within a loop](https://discourse.julialang.org/t/sync-threads-doesnt-seem-to-work-within-a-loop/20144)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 8\
**Last updated:** [January 27, 2019, 11:38am UTC](https://discourse.julialang.org/t/sync-threads-doesnt-seem-to-work-within-a-loop/20144 "2019-01-27T11:38:35Z")

</div>

I am trying to run sync\_threads() within a GPU kernel but I can’t seem to get it to work within a for loop. Here is the MWE using CuArrays, CUDAnative, CUDAdrv import Flux: cpu CuArrays.allowscalar(false) x = cu(rand(…

---

## [MNIST GPU CuArrays error](https://discourse.julialang.org/t/mnist-gpu-cuarrays-error/19695)

<div class="topic-metadata">

**Author:** [@Fadi\_Nader](https://discourse.julialang.org/u/Fadi_Nader)\
**Replies:** 23\
**Last updated:** [January 22, 2019, 3:06pm UTC](https://discourse.julialang.org/t/mnist-gpu-cuarrays-error/19695 "2019-01-22T15:06:40Z")

</div>

Hi, I’m trying to train MNIST over GPU using julia, but I face the following error. here is my code: X = hcat(float.(reshape.(imgs, :))...) |\>gpu; Y = onehotbatch(labels, 0:9) |\> gpu; batches=\[(X\[:,:,:,i\],Y\[:,i\]) for i…

---

## [Casting, annotations and numeric types for CUDAnative](https://discourse.julialang.org/t/casting-annotations-and-numeric-types-for-cudanative/19853)

<div class="topic-metadata">

**Author:** [@Alex\_Ellison](https://discourse.julialang.org/u/Alex_Ellison)\
**Replies:** 5\
**Last updated:** [January 21, 2019, 9:07pm UTC](https://discourse.julialang.org/t/casting-annotations-and-numeric-types-for-cudanative/19853 "2019-01-21T21:07:07Z")

</div>

Hello, I’ve begun exploring the CUDAnative package which modest success. I’ve run into a couple of limitations. I wanted to allocate an array from within my kernel as is shown in some of the project examples. The first…

---

## [Error of view on CuArrays with discrete indices](https://discourse.julialang.org/t/error-of-view-on-cuarrays-with-discrete-indices/19730)

<div class="topic-metadata">

**Author:** [@findmyway](https://discourse.julialang.org/u/findmyway)\
**Replies:** 0\
**Last updated:** [January 17, 2019, 4:29am UTC](https://discourse.julialang.org/t/error-of-view-on-cuarrays-with-discrete-indices/19730 "2019-01-17T04:29:31Z")

</div>

It seems that I can’t pass discrete indices (\[1,2,1\]) with view. I test the following code on both master and v0.9.0. Is there any workaround? julia\> xs = randn(3,3) 3×3 Array{Float64,2}: 1.37316 -0.378109 0.90757…

---

## [CuArray dot fuction error](https://discourse.julialang.org/t/cuarray-dot-fuction-error/19532)

<div class="topic-metadata">

**Author:** [@jianghaizhu](https://discourse.julialang.org/u/jianghaizhu)\
**Replies:** 2\
**Last updated:** [January 16, 2019, 6:22pm UTC](https://discourse.julialang.org/t/cuarray-dot-fuction-error/19532 "2019-01-16T18:22:08Z")

</div>

I am playing around some code to run on GPU. I encountered the following error. Here is a MWE. julia\> B = rand(100, 100, 2) julia\> B\_g = cu(B) julia\> B\_gv = reshape(B\_g, 10000, 2) julia\> dot(view(B\_g, :, :, 1), view(B…

---

## [Efficiency when handling jobs larger than VRAM](https://discourse.julialang.org/t/efficiency-when-handling-jobs-larger-than-vram/19570)

<div class="topic-metadata">

**Author:** [@wsphillips](https://discourse.julialang.org/u/wsphillips)\
**Replies:** 3\
**Last updated:** [January 15, 2019, 7:08am UTC](https://discourse.julialang.org/t/efficiency-when-handling-jobs-larger-than-vram/19570 "2019-01-15T07:08:37Z")

</div>

Hi! GPGPU beginner here using the CUDAnative/CuArrays stack (Thank you @maleadt for this amazing work) I am hoping to find some help regarding efficiently transferring data to and from host/device when handling input an…

---

## [Help wanted: CUDA error: an illegal memory access was encountered](https://discourse.julialang.org/t/help-wanted-cuda-error-an-illegal-memory-access-was-encountered/19488)

<div class="topic-metadata">

**Author:** [@1115](https://discourse.julialang.org/u/1115)\
**Replies:** 1\
**Last updated:** [January 11, 2019, 7:00am UTC](https://discourse.julialang.org/t/help-wanted-cuda-error-an-illegal-memory-access-was-encountered/19488 "2019-01-11T07:00:43Z")

</div>

My program got an error code 700 after running for a day, with the following error message. Can I trust the error message that the program errors at exactly where it breaks? ... step = 51, energy/site = -0.28279876708…

---

## [Is it possible to index a CuArray with a CuArray?](https://discourse.julialang.org/t/is-it-possible-to-index-a-cuarray-with-a-cuarray/18812)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 1\
**Last updated:** [January 11, 2019, 5:30am UTC](https://discourse.julialang.org/t/is-it-possible-to-index-a-cuarray-with-a-cuarray/18812 "2019-01-11T05:30:09Z")

</div>

The case is that I have a data set of indexes (rather than vectors), so I need to frequently index a multi-dimensional array (which is the table), e.g A = \[rand(3, 3, 2) for i in 1:8\] data = rand(1:2, 8, 10) # last dime…

---

## [Presentation on effective use of CUDAnative/CuArrays](https://discourse.julialang.org/t/presentation-on-effective-use-of-cudanative-cuarrays/18919)

<div class="topic-metadata">

**Author:** [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Replies:** 7\
**Last updated:** [January 3, 2019, 7:28am UTC](https://discourse.julialang.org/t/presentation-on-effective-use-of-cudanative-cuarrays/18919 "2019-01-03T07:28:17Z")

</div>

Since our GPU stack is pretty ill-documented, I figured it can’t hurt to cross-post any content there is. Here’s a recent presentation of mine that explains how the relevant packages work, with demos, as well as tips/tri…

---

## [GitLab CI for Julia GPU packages](https://discourse.julialang.org/t/gitlab-ci-for-julia-gpu-packages/11932)

<div class="topic-metadata">

**Author:** [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Replies:** 9\
**Last updated:** [December 21, 2018, 7:25pm UTC](https://discourse.julialang.org/t/gitlab-ci-for-julia-gpu-packages/11932 "2018-12-21T19:25:04Z")

</div>

Hi all, I’ve been testing GitLab CI/CD for GPU-related packages, and despite some missing features it’s been a good experience and I’ve replaced my Buildbot set-up with it. The main advantage is that there is no need fo…

---

## [GPU kernel optimization (GPU vs CPU)](https://discourse.julialang.org/t/gpu-kernel-optimization-gpu-vs-cpu/18625)

<div class="topic-metadata">

**Author:** [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Replies:** 3\
**Last updated:** [December 14, 2018, 2:54pm UTC](https://discourse.julialang.org/t/gpu-kernel-optimization-gpu-vs-cpu/18625 "2018-12-14T14:54:09Z")

</div>

I am new to CUDAnative.jl and I am trying to benchmark a very simple computational fluid dynamic model (based on the 1D linear shallow water equations). Essentially I get 3.228 s when I run the code on a CPU (i7-7700 CPU…

---

## [Timing square function in CUDA](https://discourse.julialang.org/t/timing-square-function-in-cuda/18440)

<div class="topic-metadata">

**Author:** [@cuchxq](https://discourse.julialang.org/u/cuchxq)\
**Replies:** 4\
**Last updated:** [December 11, 2018, 9:19pm UTC](https://discourse.julialang.org/t/timing-square-function-in-cuda/18440 "2018-12-11T21:19:32Z")

</div>

I am trying to compare if there is any speed benefit to use Nvidia’s math pow function than my own square kernel. Here is the code. using CuArrays, CUDAnative, CUDAdrv function square(a, ndrange) i = (blockIdx().…

---

## [CUDAnative is awesome!](https://discourse.julialang.org/t/cudanative-is-awesome/17861)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 12\
**Last updated:** [December 3, 2018, 10:47pm UTC](https://discourse.julialang.org/t/cudanative-is-awesome/17861 "2018-12-03T22:47:11Z")

</div>

Hi, I have just finished to rewrite my FEM solver with CUDAnative.jl and I want to address a big thank you to Tim and all the contributors for this package ! The performance is on par with the native C++/CUDA implement…

---

## [Multiprecision arithmetic in CUDA](https://discourse.julialang.org/t/multiprecision-arithmetic-in-cuda/18087)

<div class="topic-metadata">

**Author:** [@elaine](https://discourse.julialang.org/u/elaine)\
**Replies:** 1\
**Last updated:** [November 28, 2018, 2:17am UTC](https://discourse.julialang.org/t/multiprecision-arithmetic-in-cuda/18087 "2018-11-28T02:17:50Z")

</div>

RE: Compary or something similar Is this already implemented or can it be done in Julia and/or Python ? links to 2018 source code for multiprecision arithmetic in CUDA link to source Campary Purpose is to get multi…

---

## [How much faster is GPU compare to CPU](https://discourse.julialang.org/t/how-much-faster-is-gpu-compare-to-cpu/17533)

<div class="topic-metadata">

**Author:** [@fantapeach](https://discourse.julialang.org/u/fantapeach)\
**Replies:** 16\
**Last updated:** [November 24, 2018, 11:37pm UTC](https://discourse.julialang.org/t/how-much-faster-is-gpu-compare-to-cpu/17533 "2018-11-24T23:37:51Z")

</div>

Hi, I heard the amazing things about GPU and how much faster it can beat CPU. But I don’t know what kind of speed up is expected. So I ran a matrix multiplication to do the comparison. I ran my experiment on a server th…

---

## [Strange behavior of \`mapreduce\`](https://discourse.julialang.org/t/strange-behavior-of-mapreduce/17588)

<div class="topic-metadata">

**Author:** [@1115](https://discourse.julialang.org/u/1115)\
**Replies:** 2\
**Last updated:** [November 16, 2018, 7:49am UTC](https://discourse.julialang.org/t/strange-behavior-of-mapreduce/17588 "2018-11-16T07:49:11Z")

</div>

I have a kernel, which uses the exp operation, it breaks down in a strange way Minimum working example: using CuArrays, CUDAnative CuArrays.allowscalar(false) x = randn(1000) |\> cu CUDAnative.map(CUDAnative.exp, x) CU…

---

## [CUDAnative support for Float16](https://discourse.julialang.org/t/cudanative-support-for-float16/17369)

<div class="topic-metadata">

**Author:** [@pedramz](https://discourse.julialang.org/u/pedramz)\
**Replies:** 5\
**Last updated:** [November 15, 2018, 10:19pm UTC](https://discourse.julialang.org/t/cudanative-support-for-float16/17369 "2018-11-15T22:19:44Z")

</div>

I want to perform Float16 computation on GPU. In the vadd.jl example, when I change the rand function type from Float32 to Float16, the following error happens while running: ERROR: LoadError: InvalidIRError: compiling…

---

## [How to time CUDA Event](https://discourse.julialang.org/t/how-to-time-cuda-event/17530)

<div class="topic-metadata">

**Author:** [@cuchxq](https://discourse.julialang.org/u/cuchxq)\
**Replies:** 3\
**Last updated:** [November 15, 2018, 9:34pm UTC](https://discourse.julialang.org/t/how-to-time-cuda-event/17530 "2018-11-15T21:34:47Z")

</div>

Hi, In CUDA C, you can time how long GPU ran by using event, this will record the time for just GPU running time, which does not include data transfer. Is there a similar functionality in CuArray or other GPU packages?

---

## [cuArrays vs CUDANative](https://discourse.julialang.org/t/cuarrays-vs-cudanative/17504)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 3\
**Last updated:** [November 14, 2018, 12:38pm UTC](https://discourse.julialang.org/t/cuarrays-vs-cudanative/17504 "2018-11-14T12:38:01Z")

</div>

Hi, From a 2D Array of floats b(nx,ny), I want to compute a(nx,ny-1) on the GPU as: function julia\_diff\_y(a,b) s=size(a) for j=1:s\[2\] for i=1:s\[1\] @inbounds a\[i,j\]=b\[i,j+1\]-b\[i,j\] en…

---

## [Freeing memory in the GPU with CUDAdrv / CUDAnative / CuArrays](https://discourse.julialang.org/t/freeing-memory-in-the-gpu-with-cudadrv-cudanative-cuarrays/10946)

<div class="topic-metadata">

**Author:** [@una-dinosauria](https://discourse.julialang.org/u/una-dinosauria)\
**Replies:** 8\
**Last updated:** [November 13, 2018, 7:28pm UTC](https://discourse.julialang.org/t/freeing-memory-in-the-gpu-with-cudadrv-cudanative-cuarrays/10946 "2018-11-13T19:28:43Z")

</div>

I am writing some code that calls CUDA kernels via CUDAdrv, allocates some CuArrays and uses a generic matrix addition (which I think is done via CUDAnative). The problem I have is that after I call this code a couple o…

---

## [How to set the diagonal part of a GPU Array](https://discourse.julialang.org/t/how-to-set-the-diagonal-part-of-a-gpu-array/16975)

<div class="topic-metadata">

**Author:** [@1115](https://discourse.julialang.org/u/1115)\
**Replies:** 6\
**Last updated:** [November 12, 2018, 1:13pm UTC](https://discourse.julialang.org/t/how-to-set-the-diagonal-part-of-a-gpu-array/16975 "2018-11-12T13:13:36Z")

</div>

Let’s see the code julia\> using CuArrays; julia\> s 4-element CuArray{Float32,1}: 3.2211537 2.1344962 0.7451281 0.3308171 julia\> v 4×4 CuArray{Float32,2}: 0.267688 0.355418 -0.311468 -0.839648 -0.156514 0.…

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

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