# Lux and Flux GPU function definitions overlap

**URL:** https://discourse.julialang.org/t/lux-and-flux-gpu-function-definitions-overlap/89149
**Category:** Machine Learning
**Created:** [October 23, 2022, 3:44pm UTC](https://discourse.julialang.org/t/lux-and-flux-gpu-function-definitions-overlap/89149 "2022-10-23T15:44:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [October 23, 2022, 3:44pm UTC](https://discourse.julialang.org/t/lux-and-flux-gpu-function-definitions-overlap/89149/1 "2022-10-23T15:44:21Z")

</div>

I am running the NeuralODE example for GPUs. Here is the code:

```julia
using DifferentialEquations, Flux, DiffEqFlux, SciMLSensitivity

using Random
rng = Random.default_rng()

model_gpu = Chain(Dense(2, 50, tanh), Dense(50, 2)) |> gpu
p, re = Flux.destructure(model_gpu)
dudt!(u, p, t) = re(p)(u)

# Simulation interval and intermediary points
tspan = (0f0, 10f0)
tsteps = 0f0:1f-1:10f0

u0 = Float32[2.0; 0.0] |> gpu
prob_gpu = ODEProblem(dudt!, u0, tspan, p)

# Runs on a GPU
sol_gpu = solve(prob_gpu, Tsit5(), saveat = tsteps)

```

I get an error stating that both `DiffEqFlux` and `Lux` export `gpu`. So a choice must be made. Are the tow `gpu` implementations identical? If not, which to choose. I notice a download of relatively large libraries.

```julia
WARNING: both DiffEqFlux and Lux export "gpu"; uses of it in module Main must be qualified
ERROR: UndefVarError: gpu not defined

```

The demo can be found at `https://diffeqflux.sciml.ai/stable/examples/GPUs/` .

Thanks!

I have a suggestion, @ChrisRackauckas : why not have a discussion for the various tutorials through a link to allow people to comment on specific tutorials? Or would you rather all comments come to this forum?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 23, 2022, 5:41pm UTC](https://discourse.julialang.org/t/lux-and-flux-gpu-function-definitions-overlap/89149/2 "2022-10-23T17:41:54Z")

</div>

They export the same `gpu` function. What does `]st` give you on Julia v1.8? Are you on the latest packages?

---

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [October 23, 2022, 8:46pm UTC](https://discourse.julialang.org/t/lux-and-flux-gpu-function-definitions-overlap/89149/3 "2022-10-23T20:46:51Z")

</div>

Here you go: Julia 1.8.2:

```julia
Status `~/src/2022/ge_sciML_julia_examples/new_demos/DiffEqFlux/Project.toml`
  [052768ef] CUDA v3.12.0
  [b0b7db55] ComponentArrays v0.13.4
  [aae7a2af] DiffEqFlux v1.52.0
  [0c46a032] DifferentialEquations v7.6.0
  [587475ba] Flux v0.13.6
  [b2108857] Lux v0.4.31
  [7f7a1694] Optimization v3.9.2
  [253f991c] OptimizationFlux v0.1.1
  [36348300] OptimizationOptimJL v0.1.3
  [1dea7af3] OrdinaryDiffEq v6.29.3
  [91a5bcdd] Plots v1.35.5
  [1ed8b502] SciMLSensitivity v7.10.2
  [e88e6eb3] Zygote v0.6.49
  [9a3f8284] Random

```

When rerunning, I now get the error: gpu not found)

Here is the source code (to make sure you see what I see):  
I now longer get the error message I sent before saying that `gpu` appeared in two libraries. Note that earlier I was `using Lux`, now I am not. I also exited VSCode and reentered it, after closing my workspace. That probably deleted all my variables.

What is the best way to clear all the variables in a workspace, but leave the workspace open? LIke removing all the output in Jupyter? Surely there must be a way to do this. Otherwise, caching will complicate the debugging process. Thanks!

```julia
using DifferentialEquations, Flux, DiffEqFlux, SciMLSensitivity

using Random
rng = Random.default_rng()

model_gpu = Chain(Dense(2, 50, tanh), Dense(50, 2)) |> gpu
p, re = Flux.destructure(model_gpu)
dudt!(u, p, t) = re(p)(u)

# Simulation interval and intermediary points
tspan = (0f0, 10f0)
tsteps = 0f0:1f-1:10f0

u0 = Float32[2.0; 0.0] |> Flux.gpu
prob_gpu = ODEProblem(dudt!, u0, tspan, p)

# Runs on a GPU
sol_gpu = solve(prob_gpu, Tsit5(), saveat = tsteps)

```

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 24, 2022, 1:56am UTC](https://discourse.julialang.org/t/lux-and-flux-gpu-function-definitions-overlap/89149/4 "2022-10-24T01:56:53Z")

</div>

@avikpal what’s going on here?

---

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [October 24, 2022, 1:39pm UTC](https://discourse.julialang.org/t/lux-and-flux-gpu-function-definitions-overlap/89149/5 "2022-10-24T13:39:13Z")

</div>

Hi,

I created a MWE, with the following source in a clean project with only a single file. Thus the project file only contains the four modules below.

```julia
using DifferentialEquations, Flux, DiffEqFlux, SciMLSensitivity

gpu

```

and the gpu was found. Everything worked fine. `gpu` is defined.  
Therefore, my problem was due to the interaction with other components, and figuring this out would take too much of my time for now.

Is there an easy way to wipe the workspace of all variables without having to rebuild the Manifest? Thanks.
