Skip to content

Commit 903070f

Browse files
committed
Resolve conflicts
1 parent 3585815 commit 903070f

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
44
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
55
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
6+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
67

78
[compat]
89
Documenter = "0.26"

docs/make.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Documenter, Flux, NNlib, Functors, MLUtils
1+
using Documenter, Flux, NNlib, Functors, MLUtils, CUDA
22

33
DocMeta.setdocmeta!(Flux, :DocTestSetup, :(using Flux); recursive = true)
4-
makedocs(modules = [Flux, NNlib, Functors, MLUtils],
4+
makedocs(modules = [Flux, NNlib, Functors, MLUtils, CUDA],
55
doctest = VERSION == v"1.5",
66
sitename = "Flux",
77
pages = ["Home" => "index.md",

docs/src/gpu.md

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ NVIDIA GPU support should work out of the box on systems with CUDA and CUDNN ins
66

77
By default, Flux will run the checks on your system to see if it can support GPU functionality. You can check if Flux identified a valid GPU setup by typing the following:
88

9-
```julia
9+
```jldoctest gpu; setup = :(using Random; Random.seed!(0))
1010
julia> using CUDA
1111
1212
julia> CUDA.functional()
@@ -51,39 +51,62 @@ d(cu(rand(10)))
5151

5252
As a convenience, Flux provides the `gpu` function to convert models and data to the GPU if one is available. By default, it'll do nothing. So, you can safely call `gpu` on some data or model (as shown below), and the code will not error, regardless of whether the GPU is available or not. If the GPU library (CUDA.jl) loads successfully, `gpu` will move data from the CPU to the GPU. As is shown below, this will change the type of something like a regular array to a `CuArray`.
5353

54-
```julia
54+
```jldoctest gpu
5555
julia> using Flux, CUDA
5656
5757
julia> m = Dense(10, 5) |> gpu
58-
Dense(10 => 5)
58+
Dense(10 => 5) # 55 parameters
5959
6060
julia> x = rand(10) |> gpu
61-
10-element CuArray{Float32,1}:
62-
0.800225
63-
64-
0.511655
61+
10-element CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}:
62+
0.066846445
63+
0.15663664
64+
0.60529673
65+
0.13574456
66+
0.8381178
67+
0.914712
68+
0.30007496
69+
0.7228498
70+
0.11965257
71+
0.76706964
6572
6673
julia> m(x)
67-
5-element CuArray{Float32,1}:
68-
-0.30535
69-
70-
-0.618002
74+
5-element CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}:
75+
-0.99992573
76+
0.08930303
77+
0.4309393
78+
-0.5205649
79+
-0.547261
7180
```
7281

7382
The analogue `cpu` is also available for moving models and data back off of the GPU.
7483

75-
```julia
84+
```jldoctest gpu
7685
julia> x = rand(10) |> gpu
77-
10-element CuArray{Float32,1}:
78-
0.235164
79-
80-
0.192538
86+
10-element CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}:
87+
0.8019236
88+
0.03534455
89+
0.48466054
90+
0.8991991
91+
0.9516907
92+
0.8011185
93+
0.12432273
94+
0.114268765
95+
0.07955447
96+
0.7766742
8197
8298
julia> x |> cpu
83-
10-element Array{Float32,1}:
84-
0.235164
85-
86-
0.192538
99+
10-element Vector{Float32}:
100+
0.8019236
101+
0.03534455
102+
0.48466054
103+
0.8991991
104+
0.9516907
105+
0.8011185
106+
0.12432273
107+
0.114268765
108+
0.07955447
109+
0.7766742
87110
```
88111

89112
## Disabling CUDA or choosing which GPUs are visible to Flux

0 commit comments

Comments
 (0)