Skip to content

Commit 566a00f

Browse files
authored
Merge branch 'main' into dependabot/github_actions/dawidd6/action-download-artifact-9
2 parents 16ac6d6 + 230e90c commit 566a00f

File tree

13 files changed

+487
-215
lines changed

13 files changed

+487
-215
lines changed

.github/runs-on.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
images:
2+
quantecon_ubuntu2404:
3+
platform: "linux"
4+
arch: "x64"
5+
ami: "ami-09baf66e396fa7cfd"

.github/workflows/cache.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
name: Build Cache [using jupyter-book]
22
on:
3-
push:
4-
branches:
5-
- main
63
schedule:
74
# Execute cache weekly at 3am on Monday
85
- cron: '0 3 * * 1'
6+
workflow_dispatch:
97
jobs:
108
cache:
11-
runs-on: quantecon-gpu
12-
container:
13-
image: ghcr.io/quantecon/lecture-python-container:cuda-12.6.0-anaconda-2024-10-py312-b
14-
options: --gpus all
9+
runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large"
1510
steps:
1611
- uses: actions/checkout@v4
1712
with:
1813
ref: ${{ github.event.pull_request.head.sha }}
14+
- name: Setup Anaconda
15+
uses: conda-incubator/setup-miniconda@v3
16+
with:
17+
auto-update-conda: true
18+
auto-activate-base: true
19+
miniconda-version: 'latest'
20+
python-version: "3.12"
21+
environment-file: environment.yml
22+
activate-environment: quantecon
23+
- name: Install JAX, Numpyro
24+
shell: bash -l {0}
25+
run: |
26+
pip install --upgrade "jax[cuda12-local]"
27+
pip install numpyro
28+
python scripts/test-jax-install.py
1929
- name: Check nvidia drivers
2030
shell: bash -l {0}
2131
run: |

.github/workflows/ci.yml

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
name: Build Project [using jupyter-book]
22
on: [pull_request]
33
jobs:
4-
deploy-runner:
5-
runs-on: ubuntu-latest
6-
steps:
7-
- uses: iterative/setup-cml@v3
8-
- uses: actions/checkout@v4
9-
with:
10-
ref: ${{ github.event.pull_request.head.sha }}
11-
- name: Deploy runner on EC2
12-
env:
13-
REPO_TOKEN: ${{ secrets.QUANTECON_SERVICES_PAT }}
14-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
16-
run: |
17-
cml runner launch \
18-
--cloud=aws \
19-
--cloud-region=us-west-2 \
20-
--cloud-type=p3.2xlarge \
21-
--labels=cml-gpu \
22-
--cloud-hdd-size=50
234
preview:
24-
needs: deploy-runner
25-
runs-on: [self-hosted, cml-gpu]
26-
container:
27-
image: docker://mmcky/quantecon-lecture-python:cuda-12.3.1-anaconda-2024-02-py311
28-
options: --gpus all
5+
runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large"
296
steps:
307
- uses: actions/checkout@v4
318
with:
329
ref: ${{ github.event.pull_request.head.sha }}
33-
# Check nvidia drivers
10+
- name: Setup Anaconda
11+
uses: conda-incubator/setup-miniconda@v3
12+
with:
13+
auto-update-conda: true
14+
auto-activate-base: true
15+
miniconda-version: 'latest'
16+
python-version: "3.12"
17+
environment-file: environment.yml
18+
activate-environment: quantecon
19+
- name: Install JAX, Numpyro
20+
shell: bash -l {0}
21+
run: |
22+
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128
23+
pip install pyro-ppl
24+
pip install --upgrade "jax[cuda12-local]"
25+
pip install numpyro
26+
python scripts/test-jax-install.py
27+
# Check nvidia drivers
3428
- name: nvidia Drivers
3529
shell: bash -l {0}
3630
run: nvidia-smi

.github/workflows/collab.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build Project on Google Collab (Execution)
2+
on: [pull_request]
3+
jobs:
4+
execution-checks:
5+
runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=ubuntu24-gpu-x64/disk=large"
6+
container:
7+
image: docker://us-docker.pkg.dev/colab-images/public/runtime
8+
options: --gpus all
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
ref: ${{ github.event.pull_request.head.sha }}
13+
- name: Check nvidia drivers
14+
shell: bash -l {0}
15+
run: |
16+
nvidia-smi
17+
- name: Check python version
18+
shell: bash -l {0}
19+
run: |
20+
python --version
21+
- name: Display Pip Versions
22+
shell: bash -l {0}
23+
run: pip list
24+
- name: Download "build" folder (cache)
25+
uses: dawidd6/action-download-artifact@v3
26+
with:
27+
workflow: cache.yml
28+
branch: main
29+
name: build-cache
30+
path: _build
31+
# Install build software
32+
- name: Install Build Software
33+
shell: bash -l {0}
34+
run: |
35+
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
36+
# Build of HTML (Execution Testing)
37+
- name: Build HTML
38+
shell: bash -l {0}
39+
run: |
40+
jb build lectures --path-output ./ -n -W --keep-going
41+
- name: Upload Execution Reports
42+
uses: actions/upload-artifact@v4
43+
if: failure()
44+
with:
45+
name: execution-reports
46+
path: _build/html/reports
47+
- name: Preview Deploy to Netlify
48+
uses: nwtgck/actions-netlify@v2
49+
with:
50+
publish-dir: '_build/html/'
51+
production-branch: main
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
deploy-message: "Preview Deploy from GitHub Actions"
54+
env:
55+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
56+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

.github/workflows/linkcheck.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: ["ubuntu-latest"]
16-
python-version: ["3.11"]
16+
python-version: ["3.12"]
1717
steps:
1818
- name: Checkout
1919
uses: actions/checkout@v4
@@ -23,7 +23,7 @@ jobs:
2323
auto-update-conda: true
2424
auto-activate-base: true
2525
miniconda-version: 'latest'
26-
python-version: '3.11'
26+
python-version: '3.12'
2727
environment-file: environment.yml
2828
activate-environment: quantecon
2929
- name: Download "build" folder (cache)

.github/workflows/publish.yml

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,27 @@ on:
44
tags:
55
- 'publish*'
66
jobs:
7-
deploy-runner:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- uses: iterative/setup-cml@v3
11-
- uses: actions/checkout@v4
12-
with:
13-
ref: ${{ github.event.pull_request.head.sha }}
14-
- name: Deploy runner on EC2
15-
env:
16-
REPO_TOKEN: ${{ secrets.QUANTECON_SERVICES_PAT }}
17-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
18-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
19-
run: |
20-
cml runner launch \
21-
--cloud=aws \
22-
--cloud-region=us-west-2 \
23-
--cloud-type=p3.2xlarge \
24-
--labels=cml-gpu \
25-
--cloud-hdd-size=50
267
publish:
278
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
28-
needs: deploy-runner
29-
runs-on: [self-hosted, cml-gpu]
30-
container:
31-
image: docker://mmcky/quantecon-lecture-python:cuda-12.3.1-anaconda-2024-02-py311
32-
options: --gpus all
9+
runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large"
3310
steps:
3411
- name: Checkout
3512
uses: actions/checkout@v4
36-
- name: Install Git (required to commit notebooks)
13+
- name: Setup Anaconda
14+
uses: conda-incubator/setup-miniconda@v3
15+
with:
16+
auto-update-conda: true
17+
auto-activate-base: true
18+
miniconda-version: 'latest'
19+
python-version: "3.12"
20+
environment-file: environment.yml
21+
activate-environment: quantecon
22+
- name: Install JAX, Numpyro
3723
shell: bash -l {0}
38-
run: apt-get install -y git
24+
run: |
25+
pip install --upgrade "jax[cuda12-local]"
26+
pip install numpyro
27+
python scripts/test-jax-install.py
3928
- name: Check nvidia drivers
4029
shell: bash -l {0}
4130
run: |

environment.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,17 @@ name: quantecon
22
channels:
33
- default
44
dependencies:
5-
- python=3.11
6-
- anaconda=2024.02
5+
- python=3.12
6+
- anaconda=2024.10
77
- pip
88
- pip:
9-
- jupyter-book==0.15.1
10-
- docutils==0.17.1
11-
- quantecon-book-theme==0.7.1
12-
- sphinx-reredirects==0.1.3
9+
- jupyter-book==1.0.3
10+
- quantecon-book-theme==0.7.6
1311
- sphinx-tojupyter==0.3.0
1412
- sphinxext-rediraffe==0.2.7
15-
- sphinx-exercise==0.4.1
16-
- ghp-import==2.1.0
17-
- sphinxcontrib-youtube==1.2.0
13+
- sphinx-reredirects==0.1.4
14+
- sphinx-exercise==1.0.1
15+
- sphinx-proof==0.2.0
16+
- ghp-import==1.1.0
17+
- sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5
1818
- sphinx-togglebutton==0.3.2
19-
- arviz==0.13.0
20-
- kaleido
21-
# Docker Requirements
22-
- pytz

lectures/_admonition/gpu.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
```{admonition} GPU
2+
:class: warning
3+
4+
This lecture was built using a machine with the latest CUDA and CUDANN frameworks installed with access to a GPU.
5+
6+
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.
7+
8+
To run this lecture on your own machine, you need to install the software listed following this notice.
9+
```

lectures/ar1_bayes.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@ kernelspec:
1313

1414
# Posterior Distributions for AR(1) Parameters
1515

16-
We'll begin with some Python imports.
16+
```{include} _admonition/gpu.md
17+
```
1718

19+
```{code-cell} ipython3
20+
:tags: [hide-output]
21+
22+
!pip install numpyro jax
23+
```
24+
25+
In addition to what's included in base Anaconda, we need to install the following packages
1826

1927
```{code-cell} ipython3
2028
:tags: [hide-output]
2129
22-
!pip install arviz pymc numpyro jax
30+
!pip install arviz pymc
2331
```
2432

33+
We'll begin with some Python imports.
34+
2535
```{code-cell} ipython3
2636
2737
import arviz as az

lectures/back_prop.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,36 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.11.5
7+
jupytext_version: 1.16.7
88
kernelspec:
9-
display_name: Python 3
9+
display_name: Python 3 (ipykernel)
1010
language: python
1111
name: python3
1212
---
1313

1414
# Introduction to Artificial Neural Networks
1515

16+
```{include} _admonition/gpu.md
17+
```
18+
19+
```{code-cell} ipython3
20+
:tags: [skip-execution]
21+
22+
!pip install --upgrade jax
23+
```
24+
25+
```{code-cell} ipython3
26+
import jax
27+
## to check that gpu is activated in environment
28+
print(f"JAX backend: {jax.devices()[0].platform}")
29+
```
30+
31+
In addition to what's included in base Anaconda, we need to install the following packages
32+
1633
```{code-cell} ipython3
1734
:tags: [hide-output]
1835
19-
!pip install --upgrade jax jaxlib kaleido
36+
!pip install kaleido
2037
!conda install -y -c plotly plotly plotly-orca retrying
2138
```
2239

@@ -593,15 +610,4 @@ Image(fig.to_image(format="png"))
593610
# notebook locally
594611
```
595612
596-
```{code-cell} ipython3
597-
## to check that gpu is activated in environment
598613
599-
from jax.lib import xla_bridge
600-
print(xla_bridge.get_backend().platform)
601-
```
602-
603-
```{note}
604-
**Cloud Environment:** This lecture site is built in a server environment that doesn't have access to a `gpu`
605-
If you run this lecture locally this lets you know where your code is being executed, either
606-
via the `cpu` or the `gpu`
607-
```

0 commit comments

Comments
 (0)