start:development:scripting_languages:julia

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
start:development:scripting_languages:julia [2021/04/19 21:40]
jrutte02 [Submitting a Julia GPU Job]
start:development:scripting_languages:julia [2021/12/08 19:58] (current)
jrutte02 [Julia Modules]
Line 34: Line 34:
 JGU HPC Modules JGU HPC Modules
 ------------------- /cluster/easybuild/broadwell/modules/all ------------------- ------------------- /cluster/easybuild/broadwell/modules/all -------------------
-   lang/Julia/1.5.3-linux-x86_64    lang/Julia/1.6.0-linux-x86_64 (D)+   lang/Julia/1.5.3-linux-x86_64    lang/Julia/1.6.3-linux-x86_64 
 +   lang/Julia/1.6.0-linux-x86_64    lang/Julia/1.7.0-linux-x86_64 (D)
 </code> </code>
  
-One can use a certain version with the following command:+One can use a specific version with the following command:
  
 <code bash> <code bash>
Line 61: Line 62:
 </code> </code>
  
-For package installation, we will use the REPL (read-eval-print loop) that comes built-in to the ''julia'' executable. Start Julia using:+For package installation, we will use the REPL (read-eval-print loop) that comes built-in to the ''julia'' executable. Start Julia by using:
  
 <code bash> <code bash>
Line 81: Line 82:
 you should get an output similar to: you should get an output similar to:
  
-<code bash>+<code julia>
 (v1.6) pkg> add Dates (v1.6) pkg> add Dates
    Resolving package versions...    Resolving package versions...
Line 91: Line 92:
 Let's check the successful installation: First we display the status of the packages in our standard project: Let's check the successful installation: First we display the status of the packages in our standard project:
  
-<code bash>+<code julia>
 (v1.6) pkg> status (v1.6) pkg> status
 </code> </code>
Line 97: Line 98:
 Depending on which packages you have already installed, you should get an output similar to the following: Depending on which packages you have already installed, you should get an output similar to the following:
  
-<code bash>+<code julia>
 (v1.6) pkg> status (v1.6) pkg> status
       Status `/gpfs/fs1/home/<username>/.julia/environments/v1.6/Project.toml`       Status `/gpfs/fs1/home/<username>/.julia/environments/v1.6/Project.toml`
Line 113: Line 114:
 This indicates that ''Dates'' has been successfully installed, but let's check and confirm this with ''Pkg'' This indicates that ''Dates'' has been successfully installed, but let's check and confirm this with ''Pkg''
  
-<code bash>+<code julia>
 (v1.6) pkg> test Dates (v1.6) pkg> test Dates
      Testing Dates      Testing Dates
Line 141: Line 142:
 The installation was sucessful and ''Dates'' can now be included in ''.jl'' file via the following line: The installation was sucessful and ''Dates'' can now be included in ''.jl'' file via the following line:
  
-<code bash>+<code julia>
 using Dates using Dates
 </code> </code>
Line 186: Line 187:
 and then change to the Pkg REPL with '']'', the command line prompt should now look like: and then change to the Pkg REPL with '']'', the command line prompt should now look like:
  
-<code bash>+<code julia>
 (v1.6) pkg> (v1.6) pkg>
 </code> </code>
Line 192: Line 193:
 We are now ready to add CUDA via We are now ready to add CUDA via
  
-<code bash>+<code julia>
 (v1.6) pkg> add CUDA (v1.6) pkg> add CUDA
 </code> </code>
Line 209: Line 210:
 </code> </code>
  
-Open Julia after the modules have been successfully loaded+Open Julia by executing the following command after the modules have been successfully loaded
  
 <code bash> <code bash>
Line 216: Line 217:
  
 now enter the Pkg REPL by pressing '']'', the command line prompt should look like: now enter the Pkg REPL by pressing '']'', the command line prompt should look like:
-<code bash>+<code julia>
 (v1.6) pkg> (v1.6) pkg>
 </code> </code>
 First, the actual packages are added and then the backend is configured. Install ''Plots.jl'' with: First, the actual packages are added and then the backend is configured. Install ''Plots.jl'' with:
  
-<code bash>+<code julia>
 (v1.6) pkg> add Plots (v1.6) pkg> add Plots
 </code> </code>
Line 228: Line 229:
  
  
-<code bash>+<code julia>
 (v1.6) pkg> add PyPlot (v1.6) pkg> add PyPlot
 </code> </code>
 Afterwards, test the successful installation with: Afterwards, test the successful installation with:
-<code bash>+<code julia>
 (v1.6) pkg> test Plots (v1.6) pkg> test Plots
 </code> </code>
Line 238: Line 239:
 and and
  
-<code bash>+<code julia>
 (v1.6) pkg> test PyPlot (v1.6) pkg> test PyPlot
 </code> </code>
Line 248: Line 249:
 ^ Package ^ Comment ^ ^ Package ^ Comment ^
 | Random | |  | Random | | 
 +| CUDA | |
 | LinearAlgebra | | | LinearAlgebra | |
 | Printf| | | Printf| |
 | MPI | | | MPI | |
 | BenchmarkTools|| | BenchmarkTools||
 +| FFTW | |
  
  
 ====== Submitting a Serial Julia Job ====== ====== Submitting a Serial Julia Job ======
  
-<file bash hello_mogon.jl>+<file julia hello_mogon.jl>
 println("Hello MOGON!") println("Hello MOGON!")
 </file> </file>
Line 304: Line 307:
 But let's explore the basics of Julia's multi-threading capabilities with an example: But let's explore the basics of Julia's multi-threading capabilities with an example:
  
-<file bash hello_mogon_smp.jl>+<file julia hello_mogon_smp.jl>
  
 Threads.@threads for i=1:20 Threads.@threads for i=1:20
Line 369: Line 372:
  
  
-<file bash distributed_julia_example.jl>+<file julia distributed_julia_example.jl>
 @everywhere begin @everywhere begin
     using LinearAlgebra     using LinearAlgebra
Line 427: Line 430:
  
 ===== Using MPI with Julia ===== ===== Using MPI with Julia =====
 + Of course, you can also use MPI with Julia on MOGON. This requires you to first carry out the following setup for Julia and the MPI interface ''MPI.jl''
 +
 +
 === Julia MPI Setup === === Julia MPI Setup ===
  
Line 433: Line 439:
  
 <code bash> <code bash>
-module load mpi/OpenMPI/4.0.5-GCC-10.2.0+module load mpi/OpenMPI/4.0.3-GCC-9.3.0
 module load lang/Julia module load lang/Julia
 </code> </code>
Line 444: Line 450:
 The output should should be similar to the following if installation and build was successful: The output should should be similar to the following if installation and build was successful:
  
-<code bash>+<code julia>
 [ ... ] [ ... ]
 [ Info: using system MPI                              0/1 [ Info: using system MPI                              0/1
Line 450: Line 456:
 │   libmpi = "libmpi" │   libmpi = "libmpi"
 │   mpiexec_cmd = `mpiexec` │   mpiexec_cmd = `mpiexec`
-└   MPI_LIBRARY_VERSION_STRING = "Open MPI v4.0.5, package: Open MPI henkela@login22.mogon Distribution, ident: 4.0.5, repo rev: v4.0.5Aug 26, 2020\0"+└   MPI_LIBRARY_VERSION_STRING = "Open MPI v4.0.3, package: Open MPI henkela@z0590.mogon Distribution, ident: 4.0.3, repo rev: v4.0.3Mar 03, 2020\0"
 ┌ Info: MPI implementation detected ┌ Info: MPI implementation detected
 │   impl = OpenMPI::MPIImpl = 2 │   impl = OpenMPI::MPIImpl = 2
-│   version = v"4.0.5"+│   version = v"4.0.3"
 └   abi = "OpenMPI" └   abi = "OpenMPI"
 +
 +1 dependency successfully precompiled in 3 seconds (140 already precompiled, 1 skipped during auto due to previous errors)
 </code> </code>
  
Line 460: Line 468:
 Now that MPI and Julia have been set up correctly, we can proceed to the example. Now that MPI and Julia have been set up correctly, we can proceed to the example.
  
-<file bash hello_mogon_mpi.jl>+<file julia hello_mogon_mpi.jl>
 using MPI using MPI
  
Line 520: Line 528:
 ====== Submitting a Julia GPU Job ====== ====== Submitting a Julia GPU Job ======
  
 +Before you start parallelising with Julia on MOGON GPUs, you need to prepare your Julia environemnt for the usage pf GPUs, as we explaind earlier in the Article about [[https://mogonwiki.zdv.uni-mainz.de/dokuwiki/start:development:scripting_languages:julia#pkg_-_cuda|CUDA.jl]]. After successfully setting up ''CUDA.jl'', you can directly start utilising the advantages of GPUs. We have given some examples below to make it easier for you to start using Julia on MOGON GPUs and to somewhat reflect the advantages of GPUs.
  
  
Line 528: Line 537:
 The theoretical bandwidth per lane for **PCIe 3.0** is $0.985 GB/s$. For the GTX 1080Ti (**PCIe3 x16**) used in our MOGON GPU nodes the 16-lane slot could theoretical give $15.754 GB/s$.(( This example was taken from the [[https://de.mathworks.com/help/parallel-computing/measuring-gpu-performance.html|MATLAB Help Center]] and adapted.)) The theoretical bandwidth per lane for **PCIe 3.0** is $0.985 GB/s$. For the GTX 1080Ti (**PCIe3 x16**) used in our MOGON GPU nodes the 16-lane slot could theoretical give $15.754 GB/s$.(( This example was taken from the [[https://de.mathworks.com/help/parallel-computing/measuring-gpu-performance.html|MATLAB Help Center]] and adapted.))
  
-<file bash gpu_rw_perf.jl>+<file julia gpu_rw_perf.jl>
 using LinearAlgebra using LinearAlgebra
 using Plots using Plots
Line 676: Line 685:
 The difference to our MATLAB article is of course the adaptation to native Julia code. But even so, we have made a few alterations due to the use of the Julia language. When defining vectors or arrays, we have purposely chosen ''Float32'', since GPUs are faster when working with ''Float32'' than with ''Float64''. In addition ''CuArrys'' are by default ''Float32'', as well as functions like ''CUDA.rand'' or ''CUDA.zeros''. The difference to our MATLAB article is of course the adaptation to native Julia code. But even so, we have made a few alterations due to the use of the Julia language. When defining vectors or arrays, we have purposely chosen ''Float32'', since GPUs are faster when working with ''Float32'' than with ''Float64''. In addition ''CuArrys'' are by default ''Float32'', as well as functions like ''CUDA.rand'' or ''CUDA.zeros''.
  
-<file bash gpu_perf.jl>+<file julia gpu_perf.jl>
 using LinearAlgebra using LinearAlgebra
 using Plots using Plots
  • start/development/scripting_languages/julia.1618861210.txt.gz
  • Last modified: 2021/04/19 21:40
  • by jrutte02