Skip to main content

4 - Execute the Tutorial Notebook

Why this guide's resources? This guide adds no new cloud resources; it uses what guides 1-3 built: the Jupyter server (or VS Code) on the GPU VM as the interface, and the GPU itself, which CUDA.jl reports so you can confirm the simulation really runs on it. See 0 - The Cloud Resources in This Tutorial for how the pieces fit together.

Goal: Learn how to execute the ocean modeling tutorial notebook in either Jupyter Browser or VS Code, and how to verify that the GPU is correctly detected and utilized.

Step 1: Open the Notebook​

Depending on which method you used to connect to your GPU instance, open the ocean_gpu_tutorial.ipynb notebook.

Using Jupyter via Browser (from Tutorial 2)​

  1. Ensure your Jupyter server is running and you have connected via your browser.
  2. In the file browser on the left, navigate to the gpu_computing_oceanography folder.
  3. Double-click ocean_gpu_tutorial.ipynb to open it.

Using VS Code Remote (from Tutorial 3)​

  1. Ensure you are connected to the server via VS Code Remote SSH.
  2. In the Explorer view on the left, navigate to the gpu_computing_oceanography folder.
  3. Click on ocean_gpu_tutorial.ipynb to open it. Make sure you select a "Julia" kernel when prompted.

Step 2: Run the Notebook and Verify GPU​

1. Verify the Environment​

Click on the first code cell and run it (Shift + Enter).

using Pkg
Pkg.build("CUDA")
using CUDA
CUDA.versioninfo()

2. Verify GPU Detection​

Once the first cell finishes executing, look closely at the output generated by the CUDA.versioninfo() command.

How to verify everything is working:

  • CUDA Toolchain: It should list the runtime, driver, and compiler versions (e.g., driver 580+).
  • Julia Packages: It will show versions of CUDA.jl and related GPU packages.
  • Device: The most critical part is at the very bottom. You should see 1 device: listed, followed by details of the GPU.
    • Expected: 0: Tesla T4 (sm_75, 14.559 GiB / 15.000 GiB available)
    • If it says 0 devices or there is an error, the GPU is not correctly attached or the drivers are not installed. Double-check your Google Cloud VM configuration and initialization steps.

Versions: The versions in this tutorial (Julia 1.11.9, Python/Ubuntu packages) are as of October 2026. Exact patch versions may differ slightly on a fresh install; that is normal and does not affect the tutorial. Do not change the Reactant package version: it is pinned by the setup guide (step 10 of guide 1) because the newest Reactant breaks this notebook.

Step 3: Execute the Simulation​

Proceed to run the subsequent cells in the notebook.

  • The notebook will set up a grid and configure the ocean architecture.
  • It will initialize the variables (e.g. Nx=48, Ny=96, Nz=32).
  • You'll observe output detailing the time steps and simulation progress, taking advantage of the GPU.
  • The final cell will visualize the results (e.g., "Surface Temperature" heatmap) using CairoMakie, confirming the simulation successfully executed and produced data.

Optional: Execute the notebook headless with nbconvert​

Instead of the Jupyter UI, you can execute and re-render the notebook from a terminal:

jupyter nbconvert --to notebook --execute --inplace \
--ExecutePreprocessor.kernel_name=julia-1.11 ocean_gpu_tutorial.ipynb

The --ExecutePreprocessor.kernel_name value must match an installed kernel, or nbconvert --execute stops with NoSuchKernel. Check the installed names with jupyter kernelspec list (a fresh IJulia install registers julia-1.11, which is also what the notebook metadata declares). If the notebook metadata and the installed kernel name differ, either fix the notebook metadata or pass the name that is actually installed.