From 653329366f2393af016e50690eedbf901196cbad Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 8 May 2025 10:08:10 +1000 Subject: [PATCH 01/10] MAINT: remove installs of gpu related software --- lectures/ar1_bayes.md | 2 +- lectures/back_prop.md | 7 ++++++- lectures/bayes_nonconj.md | 2 +- lectures/mix_model.md | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lectures/ar1_bayes.md b/lectures/ar1_bayes.md index 913e6f99e..11a5faf4d 100644 --- a/lectures/ar1_bayes.md +++ b/lectures/ar1_bayes.md @@ -17,7 +17,7 @@ We'll begin with some Python imports. ```{code-cell} ipython3 -:tags: [hide-output] +:tags: [hide-output, skip-execution] !pip install arviz pymc numpyro jax ``` diff --git a/lectures/back_prop.md b/lectures/back_prop.md index a7323729f..4964ece06 100644 --- a/lectures/back_prop.md +++ b/lectures/back_prop.md @@ -14,9 +14,14 @@ kernelspec: # Introduction to Artificial Neural Networks ```{code-cell} ipython3 -:tags: [hide-output] +:tags: [skip-execution] !pip install --upgrade jax jaxlib kaleido +``` + +```{code-cell} ipython3 +:tags: [hide-output] + !conda install -y -c plotly plotly plotly-orca retrying ``` diff --git a/lectures/bayes_nonconj.md b/lectures/bayes_nonconj.md index 3a466b0b3..b187e0757 100644 --- a/lectures/bayes_nonconj.md +++ b/lectures/bayes_nonconj.md @@ -44,7 +44,7 @@ The two Python modules are As usual, we begin by importing some Python code. ```{code-cell} ipython3 -:tags: [hide-output] +:tags: [hide-output, skip-execution] # install dependencies !pip install numpyro pyro-ppl torch jax diff --git a/lectures/mix_model.md b/lectures/mix_model.md index 37d8a5f6e..d7f976b2c 100644 --- a/lectures/mix_model.md +++ b/lectures/mix_model.md @@ -15,9 +15,10 @@ kernelspec: # Incorrect Models In addition to what's in Anaconda, this lecture will need the following libraries: + ```{code-cell} ipython --- -tags: [hide-output] +tags: [hide-output, skip-execution] --- !pip install numpyro jax ``` From ca4f70707e18b93eef508c5d250f66120efc1e5a Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 May 2025 10:25:38 +1000 Subject: [PATCH 02/10] Update lectures requiring GPU access --- lectures/_admonition/gpu.md | 9 +++++++++ lectures/ar1_bayes.md | 8 +++++--- lectures/back_prop.md | 3 +++ lectures/bayes_nonconj.md | 16 +++++++++------- lectures/mix_model.md | 8 ++++---- 5 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 lectures/_admonition/gpu.md diff --git a/lectures/_admonition/gpu.md b/lectures/_admonition/gpu.md new file mode 100644 index 000000000..8f2e2bd04 --- /dev/null +++ b/lectures/_admonition/gpu.md @@ -0,0 +1,9 @@ +```{admonition} GPU +:class: warning + +This lecture was built using a machine with the latest CUDA and CUDANN frameworks installed with access to a GPU. + +To run this lecture on [Google Colab](https://colab.research.google.com/), click on the "play" icon top right, select Colab, and set the runtime environment to include a GPU. + +To run this lecture on your own machine, you need to install the software listed following this notice. +``` diff --git a/lectures/ar1_bayes.md b/lectures/ar1_bayes.md index 11a5faf4d..9da9fb9b5 100644 --- a/lectures/ar1_bayes.md +++ b/lectures/ar1_bayes.md @@ -13,15 +13,17 @@ kernelspec: # Posterior Distributions for AR(1) Parameters -We'll begin with some Python imports. - +```{include} _admonition/gpu.md +``` ```{code-cell} ipython3 -:tags: [hide-output, skip-execution] +:tags: [skip-execution] !pip install arviz pymc numpyro jax ``` +We'll begin with some Python imports. + ```{code-cell} ipython3 import arviz as az diff --git a/lectures/back_prop.md b/lectures/back_prop.md index 4964ece06..0a43352e4 100644 --- a/lectures/back_prop.md +++ b/lectures/back_prop.md @@ -13,6 +13,9 @@ kernelspec: # Introduction to Artificial Neural Networks +```{include} _admonition/gpu.md +``` + ```{code-cell} ipython3 :tags: [skip-execution] diff --git a/lectures/bayes_nonconj.md b/lectures/bayes_nonconj.md index b187e0757..0927e7f9a 100644 --- a/lectures/bayes_nonconj.md +++ b/lectures/bayes_nonconj.md @@ -13,6 +13,15 @@ kernelspec: # Non-Conjugate Priors +```{include} _admonition/gpu.md +``` + +```{code-cell} ipython3 +:tags: [skip-execution] + +!pip install numpyro pyro-ppl torch jax +``` + This lecture is a sequel to the {doc}`quantecon lecture `. That lecture offers a Bayesian interpretation of probability in a setting in which the likelihood function and the prior distribution @@ -43,13 +52,6 @@ The two Python modules are As usual, we begin by importing some Python code. -```{code-cell} ipython3 -:tags: [hide-output, skip-execution] - -# install dependencies -!pip install numpyro pyro-ppl torch jax -``` - ```{code-cell} ipython3 import numpy as np import seaborn as sns diff --git a/lectures/mix_model.md b/lectures/mix_model.md index d7f976b2c..5cd887ecb 100644 --- a/lectures/mix_model.md +++ b/lectures/mix_model.md @@ -14,12 +14,12 @@ kernelspec: (likelihood-ratio-process)= # Incorrect Models -In addition to what's in Anaconda, this lecture will need the following libraries: +```{include} _admonition/gpu.md +``` ```{code-cell} ipython ---- -tags: [hide-output, skip-execution] ---- +:tags: [skip-execution] + !pip install numpyro jax ``` From 12fc8396b250bed942a40662824a0e0dd7aa3292 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 May 2025 11:29:57 +1000 Subject: [PATCH 03/10] add arviz to environment --- environment.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index f69c4ec3a..2e29654b7 100644 --- a/environment.yml +++ b/environment.yml @@ -16,6 +16,4 @@ dependencies: - ghp-import==1.1.0 - sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5 - sphinx-togglebutton==0.3.2 - # Docker Requirements - - pytz - + - arviz From 5641c5fa6b10d26042770f5b90ada04a97c65ce1 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 May 2025 11:43:57 +1000 Subject: [PATCH 04/10] fix installs at the lecture level for non-gpu packages --- environment.yml | 1 - lectures/ar1_bayes.md | 10 +++++++++- lectures/back_prop.md | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index 2e29654b7..203de148f 100644 --- a/environment.yml +++ b/environment.yml @@ -16,4 +16,3 @@ dependencies: - ghp-import==1.1.0 - sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5 - sphinx-togglebutton==0.3.2 - - arviz diff --git a/lectures/ar1_bayes.md b/lectures/ar1_bayes.md index 9da9fb9b5..f64132d47 100644 --- a/lectures/ar1_bayes.md +++ b/lectures/ar1_bayes.md @@ -19,7 +19,15 @@ kernelspec: ```{code-cell} ipython3 :tags: [skip-execution] -!pip install arviz pymc numpyro jax +!pip install numpyro jax +``` + +In addition to what's included in base Anaconda, we need to install the following packages + +```{code-cell} ipython3 +:tags: [hide-output] + +!pip install arviz pymc ``` We'll begin with some Python imports. diff --git a/lectures/back_prop.md b/lectures/back_prop.md index 0a43352e4..07bb957cf 100644 --- a/lectures/back_prop.md +++ b/lectures/back_prop.md @@ -19,12 +19,15 @@ kernelspec: ```{code-cell} ipython3 :tags: [skip-execution] -!pip install --upgrade jax jaxlib kaleido +!pip install --upgrade jax ``` +In addition to what's included in base Anaconda, we need to install the following packages + ```{code-cell} ipython3 :tags: [hide-output] +!pip install kaleido !conda install -y -c plotly plotly plotly-orca retrying ``` From 1f84a06f86f85d7a3b87b8b95239c53b865364e3 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 May 2025 11:45:04 +1000 Subject: [PATCH 05/10] add pyro-ppl package to GPU packages --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 663720fd2..ddea1f690 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,7 @@ jobs: shell: bash -l {0} run: | pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128 + pip install pyro-ppl pip install --upgrade "jax[cuda12-local]" pip install numpyro python scripts/test-jax-install.py From 77fcd79240ddf66bc16298f1ae1e8fa6c9e7ee22 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 May 2025 14:15:22 +1000 Subject: [PATCH 06/10] switch to hide-output for collab compat testing --- lectures/ar1_bayes.md | 2 +- lectures/bayes_nonconj.md | 2 +- lectures/mix_model.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lectures/ar1_bayes.md b/lectures/ar1_bayes.md index f64132d47..e553b38c8 100644 --- a/lectures/ar1_bayes.md +++ b/lectures/ar1_bayes.md @@ -17,7 +17,7 @@ kernelspec: ``` ```{code-cell} ipython3 -:tags: [skip-execution] +:tags: [hide-output] !pip install numpyro jax ``` diff --git a/lectures/bayes_nonconj.md b/lectures/bayes_nonconj.md index 0927e7f9a..6d586e4e3 100644 --- a/lectures/bayes_nonconj.md +++ b/lectures/bayes_nonconj.md @@ -17,7 +17,7 @@ kernelspec: ``` ```{code-cell} ipython3 -:tags: [skip-execution] +:tags: [hide-output] !pip install numpyro pyro-ppl torch jax ``` diff --git a/lectures/mix_model.md b/lectures/mix_model.md index 5cd887ecb..3e324c18f 100644 --- a/lectures/mix_model.md +++ b/lectures/mix_model.md @@ -18,7 +18,7 @@ kernelspec: ``` ```{code-cell} ipython -:tags: [skip-execution] +:tags: [hide-output] !pip install numpyro jax ``` From f19e92d5bb457c6217d13869c9d6e9ed1288532f Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 May 2025 15:49:58 +1000 Subject: [PATCH 07/10] ensure latest collab docker runtime is used --- .github/workflows/collab.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/collab.yml b/.github/workflows/collab.yml index 40d996535..c865576e0 100644 --- a/.github/workflows/collab.yml +++ b/.github/workflows/collab.yml @@ -4,7 +4,7 @@ jobs: execution-checks: runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=ubuntu24-gpu-x64/disk=large" container: - image: docker://us-docker.pkg.dev/colab-images/public/runtime + image: docker://us-docker.pkg.dev/colab-images/public/runtime:latest options: --gpus all steps: - uses: actions/checkout@v4 From d8cbcdca892968ca9b0810a6837fba01d2c54f20 Mon Sep 17 00:00:00 2001 From: mmcky Date: Mon, 12 May 2025 11:11:17 +1000 Subject: [PATCH 08/10] add arviz to environment --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index 203de148f..2e29654b7 100644 --- a/environment.yml +++ b/environment.yml @@ -16,3 +16,4 @@ dependencies: - ghp-import==1.1.0 - sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5 - sphinx-togglebutton==0.3.2 + - arviz From 14b17139a0d8cceca978e498da827ba1a55026f5 Mon Sep 17 00:00:00 2001 From: mmcky Date: Mon, 12 May 2025 12:47:11 +1000 Subject: [PATCH 09/10] ensure latest arviz in collab --- .github/workflows/collab.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/collab.yml b/.github/workflows/collab.yml index c865576e0..a9ad5b0f2 100644 --- a/.github/workflows/collab.yml +++ b/.github/workflows/collab.yml @@ -10,6 +10,10 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} + - name: Install latest arviz + shell: bash -l {0} + run: | + pip install --upgrade arviz - name: Check nvidia drivers shell: bash -l {0} run: | From cbc97a7223a0a1d6214cd89294a57327cdcdf3ae Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 13 May 2025 15:50:40 +1000 Subject: [PATCH 10/10] update collab build software --- .github/workflows/collab.yml | 6 +----- environment.yml | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/collab.yml b/.github/workflows/collab.yml index a9ad5b0f2..7f047f794 100644 --- a/.github/workflows/collab.yml +++ b/.github/workflows/collab.yml @@ -10,10 +10,6 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - - name: Install latest arviz - shell: bash -l {0} - run: | - pip install --upgrade arviz - name: Check nvidia drivers shell: bash -l {0} run: | @@ -36,7 +32,7 @@ jobs: - name: Install Build Software shell: bash -l {0} run: | - pip install jupyter-book==0.15.1 docutils==0.17.1 quantecon-book-theme==0.7.2 sphinx-tojupyter==0.3.0 sphinxext-rediraffe==0.2.7 sphinx-reredirects sphinx-exercise==0.4.1 sphinxcontrib-youtube==1.1.0 sphinx-togglebutton==0.3.1 arviz==0.13.0 sphinx-proof + pip install jupyter-book==1.0.3 quantecon-book-theme==0.8.2 sphinx-tojupyter==0.3.0 sphinxext-rediraffe==0.2.7 sphinxcontrib-youtube==1.3.0 sphinx-togglebutton==0.3.2 arviz sphinx-proof sphinx-exercise sphinx-reredirects # Build of HTML (Execution Testing) - name: Build HTML shell: bash -l {0} diff --git a/environment.yml b/environment.yml index 2e29654b7..203de148f 100644 --- a/environment.yml +++ b/environment.yml @@ -16,4 +16,3 @@ dependencies: - ghp-import==1.1.0 - sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5 - sphinx-togglebutton==0.3.2 - - arviz