# Using GPU with NeuralPDE on M1 Mac

**URL:** <https://discourse.julialang.org/t/using-gpu-with-neuralpde-on-m1-mac/90112>\
**Category:** GPU\
**Tags:** sciml\
**Created:** [November 11, 2022, 10:34am UTC](https://discourse.julialang.org/t/using-gpu-with-neuralpde-on-m1-mac/90112 "2022-11-11T10:34:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MilesCB](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescb/32/44347_2.png) [@MilesCB](https://discourse.julialang.org/u/MilesCB)\
**Post date:** [November 11, 2022, 10:34am UTC](https://discourse.julialang.org/t/using-gpu-with-neuralpde-on-m1-mac/90112/1 "2022-11-11T10:34:33Z")

</div>

I’m currently using `NeuralPDE.jl` to learn the solution to various PDEs. Everything is working well, however I would like to train on GPUs to speed up some of my processing. For building the neural networks I am using `Lux.jl`. When I try and move parameters of the network to the GPU for training using the following code

```julia
ps = Lux.setup(Random.default_rng())
ps = ps |> Lux.ComponentArray |> gpu .|> Float32

```

I get the output

```julia
┌ Info: The GPU function is being called but the GPU is not accessible.
│ Defaulting back to the CPU. (No action is required if you want
└ to run on the CPU).

```

Is there anything special I need to do for an M1 Mac or is the GPU currently not accessible with Julia and NeuralPDE?

Here are the packages and versions I am using:

```julia
  [052768ef] CUDA v3.12.0
  [aae7a2af] DiffEqFlux v1.52.0
  [0c46a032] DifferentialEquations v7.6.0
  [5b8099bc] DomainSets v0.5.14
  [033835bb] JLD2 v0.4.26
  [b2108857] Lux v0.4.33
  [961ee093] ModelingToolkit v8.33.0
  [315f7962] NeuralPDE v5.3.0
  [7f7a1694] Optimization v3.9.2
  [36348300] OptimizationOptimJL v0.1.4
  [42dfb2eb] OptimizationOptimisers v0.1.0
  [1dea7af3] OrdinaryDiffEq v6.31.2
  [91a5bcdd] Plots v1.36.1
  [f2b01f46] Roots v2.0.8
  [1ed8b502] SciMLSensitivity v7.11.0
  [90137ffa] StaticArrays v1.5.9
  [9a3f8284] Random
  [10745b16] Statistics

```

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![cmarcotte](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@cmarcotte](https://discourse.julialang.org/u/cmarcotte)\
**Post date:** [November 11, 2022, 10:49am UTC](https://discourse.julialang.org/t/using-gpu-with-neuralpde-on-m1-mac/90112/2 "2022-11-11T10:49:09Z")

</div>

On the [`NeuralPDE.jl` “Using GPUs” page](https://neuralpde.sciml.ai/stable/tutorials/gpu/) you may notice `using [...] CUDA [...]` in the example. CUDA is an Nvidia-only option; as of now, I think the only M1-GPU option is to use [`Metal.jl`](https://github.com/JuliaGPU/Metal.jl) which is in relative infancy and definitely not as automatic as CUDA is.

---

<div class="post-metadata">

**Author:** ![MilesCB](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescb/32/44347_2.png) [@MilesCB](https://discourse.julialang.org/u/MilesCB)\
**Post date:** [November 11, 2022, 10:53am UTC](https://discourse.julialang.org/t/using-gpu-with-neuralpde-on-m1-mac/90112/3 "2022-11-11T10:53:29Z")

</div>

Ah, thank you! This makes a lot of sense.
