From 63f7a8b9ee83a3405f5d2552ad90682455a8fb7d Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 8 May 2025 17:07:38 +1000 Subject: [PATCH 1/8] ENH: enable RunsOn with custom ami --- .github/workflows/ci.yml | 24 ++++++++++++++++++------ scripts/test-jax-install.py | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 scripts/test-jax-install.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 115186510..2b704dd6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,16 +2,28 @@ name: Build Project [using jupyter-book] on: [pull_request] jobs: preview: - runs-on: quantecon-gpu - container: - image: ghcr.io/quantecon/lecture-python-container:cuda-12.8.1-anaconda-2024-10-py312 - options: --gpus all + runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2204_ami/disk=large" steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - # Check nvidia drivers - - name: nvidia Drivers + - name: Setup Anaconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + auto-activate-base: true + miniconda-version: 'latest' + python-version: "3.12" + environment-file: environment.yml + activate-environment: quantecon + - name: Install JAX, Numpyro, PyTorch + shell: bash -l {0} + run: | + pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128 + pip install --upgrade "jax[cuda12-local]" + pip install numpyro + python scripts/test-jax-install.py + - name: Check nvidia Drivers shell: bash -l {0} run: nvidia-smi - name: Display Conda Environment Versions diff --git a/scripts/test-jax-install.py b/scripts/test-jax-install.py new file mode 100644 index 000000000..988a6ceaa --- /dev/null +++ b/scripts/test-jax-install.py @@ -0,0 +1,21 @@ +import jax +import jax.numpy as jnp + +devices = jax.devices() +print(f"The available devices are: {devices}") + +@jax.jit +def matrix_multiply(a, b): + return jnp.dot(a, b) + +# Example usage: +key = jax.random.PRNGKey(0) +x = jax.random.normal(key, (1000, 1000)) +y = jax.random.normal(key, (1000, 1000)) +z = matrix_multiply(x, y) + +# Now the function is JIT compiled and will likely run on GPU (if available) +print(z) + +devices = jax.devices() +print(f"The available devices are: {devices}") \ No newline at end of file From a60740a3030f26c526793cec741174c8dbcfb812 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 8 May 2025 17:08:52 +1000 Subject: [PATCH 2/8] fix custom ami name for RunsOn --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b704dd6c..731211132 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: Build Project [using jupyter-book] on: [pull_request] jobs: preview: - runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2204_ami/disk=large" + runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large" steps: - uses: actions/checkout@v4 with: From 10fff7e43a2945e7b480e4feed8240fc1ad870ea Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 8 May 2025 17:19:57 +1000 Subject: [PATCH 3/8] use g4dn.xlarge --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 731211132..110b0ea2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: Build Project [using jupyter-book] on: [pull_request] jobs: preview: - runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large" + runs-on: "runs-on=${{ github.run_id }}/family=g4dn.xlarge/image=quantecon_ubuntu2404/disk=large" steps: - uses: actions/checkout@v4 with: From 1b281983da7f4fafd06aa15fe68672180977cd9a Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 8 May 2025 20:05:18 +1000 Subject: [PATCH 4/8] enable manual trigering' --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 110b0ea2d..23c1790ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,7 @@ name: Build Project [using jupyter-book] -on: [pull_request] +on: + pull_request: + workflow_dispatch: jobs: preview: runs-on: "runs-on=${{ github.run_id }}/family=g4dn.xlarge/image=quantecon_ubuntu2404/disk=large" From 5bfbd38ccc6f44f56f47f8d5ced74940576392e5 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 8 May 2025 20:16:29 +1000 Subject: [PATCH 5/8] use 2xlarge instance --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23c1790ca..663720fd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: jobs: preview: - runs-on: "runs-on=${{ github.run_id }}/family=g4dn.xlarge/image=quantecon_ubuntu2404/disk=large" + runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large" steps: - uses: actions/checkout@v4 with: From f18500e8b07b4cdf102597351ec1058628a74abf Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 8 May 2025 20:16:41 +1000 Subject: [PATCH 6/8] tmp: disable build cache --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 663720fd2..ab8a4e2c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,13 +34,13 @@ jobs: - name: Display Pip Versions shell: bash -l {0} run: pip list - - name: Download "build" folder (cache) - uses: dawidd6/action-download-artifact@v9 - with: - workflow: cache.yml - branch: main - name: build-cache - path: _build + # - name: Download "build" folder (cache) + # uses: dawidd6/action-download-artifact@v9 + # with: + # workflow: cache.yml + # branch: main + # name: build-cache + # path: _build # Build Assets (Download Notebooks and PDF via LaTeX) - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} From 8285f4e1e4ec573e227859d6b74e54a0439cada8 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 May 2025 08:59:32 +1000 Subject: [PATCH 7/8] Revert "tmp: disable build cache" This reverts commit f18500e8b07b4cdf102597351ec1058628a74abf. --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab8a4e2c9..663720fd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,13 +34,13 @@ jobs: - name: Display Pip Versions shell: bash -l {0} run: pip list - # - name: Download "build" folder (cache) - # uses: dawidd6/action-download-artifact@v9 - # with: - # workflow: cache.yml - # branch: main - # name: build-cache - # path: _build + - name: Download "build" folder (cache) + uses: dawidd6/action-download-artifact@v9 + with: + workflow: cache.yml + branch: main + name: build-cache + path: _build # Build Assets (Download Notebooks and PDF via LaTeX) - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} From a72614ffb455c0639d23fab6442beb8e729d3e3a Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 May 2025 09:03:44 +1000 Subject: [PATCH 8/8] convert cache, collab and publish to use runson --- .github/workflows/cache.yml | 21 +++++++++++++++++---- .github/workflows/collab.yml | 2 +- .github/workflows/publish.yml | 22 ++++++++++++++++------ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 7e7c6ef42..c499a1599 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -6,14 +6,27 @@ on: workflow_dispatch: jobs: cache: - runs-on: quantecon-gpu - container: - image: ghcr.io/quantecon/lecture-python-container:cuda-12.8.1-anaconda-2024-10-py312 - options: --gpus all + runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large" steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} + - name: Setup Anaconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + auto-activate-base: true + miniconda-version: 'latest' + python-version: "3.12" + environment-file: environment.yml + activate-environment: quantecon + - name: Install JAX, Numpyro, PyTorch + shell: bash -l {0} + run: | + pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128 + pip install --upgrade "jax[cuda12-local]" + pip install numpyro + python scripts/test-jax-install.py - name: Check nvidia drivers shell: bash -l {0} run: | diff --git a/.github/workflows/collab.yml b/.github/workflows/collab.yml index efd21e264..40d996535 100644 --- a/.github/workflows/collab.yml +++ b/.github/workflows/collab.yml @@ -2,7 +2,7 @@ name: Build Project on Google Collab (Execution) on: [pull_request] jobs: execution-checks: - runs-on: quantecon-gpu + 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 options: --gpus all diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 52d194208..cba997aed 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,16 +6,26 @@ on: jobs: publish: if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - runs-on: quantecon-gpu - container: - image: ghcr.io/quantecon/lecture-python-container:cuda-12.8.1-anaconda-2024-10-py312 - options: --gpus all + runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/disk=large" steps: - name: Checkout uses: actions/checkout@v4 - - name: Install Git (required to commit notebooks) + - name: Setup Anaconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + auto-activate-base: true + miniconda-version: 'latest' + python-version: "3.12" + environment-file: environment.yml + activate-environment: quantecon + - name: Install JAX, Numpyro, PyTorch shell: bash -l {0} - run: apt-get install -y git + run: | + pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128 + pip install --upgrade "jax[cuda12-local]" + pip install numpyro + python scripts/test-jax-install.py - name: Check nvidia drivers shell: bash -l {0} run: |