Skip to content

Commit

Permalink
build profiling image in CI, add arm64 support to AWS notebooks (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Dec 31, 2024
1 parent ad1f068 commit 59250f3
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 16 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
!LightGBM/python-package
!LightGBM/src
!LightGBM/swig
!LightGBM/windows
!LightGBM/VERSION.txt
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
- name: Build cluster image
run: |
make cluster-image
- name: Build profiling image
run: |
make profiling-image
all-tests-successful:
if: always()
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG BASE_IMAGE=unset
# hadolint ignore=DL3006
FROM ${BASE_IMAGE}

RUN --mount=type=bind,source=LightGBM,target=/tmp/LightGBM \
RUN --mount=type=bind,source=LightGBM,target=/tmp/LightGBM,rw \
<<EOF
cd /tmp/LightGBM

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-notebook
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM ${BASE_IMAGE}

COPY jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py

RUN --mount=type=bind,source=LightGBM,target=/tmp/LightGBM \
RUN --mount=type=bind,source=LightGBM,target=/tmp/LightGBM,rw \
<<EOF
cd /tmp/LightGBM

Expand Down
14 changes: 8 additions & 6 deletions Dockerfile-profiling
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ ARG BASE_IMAGE=unset
# hadolint ignore=DL3006
FROM ${BASE_IMAGE}

RUN pip install --no-cache-dir --prefer-binary \
memray \
pytest \
pytest-memray \
pytest-profiling \
snakeviz
RUN <<EOF
pip install --no-cache-dir --prefer-binary \
memray \
pytest \
pytest-memray \
pytest-profiling \
snakeviz
EOF

COPY bin/profile-examples.sh /usr/local/bin/profile-examples.sh
COPY bin/profile-example-memory-usage.sh /usr/local/bin/profile-example-memory-usage.sh
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ push-image: create-repo
docker push \
$$(cat ./ecr-details.json | jq .'repository'.'repositoryUri' | tr -d '"'):${IMAGE_TAG}

# NOTE: IMAGE_TAG is in the environment here so the AWS notebooks
# know what image to use for the Dask cluster
.PHONY: start-notebook
start-notebook:
docker run \
Expand All @@ -208,6 +210,7 @@ start-notebook:
--env AWS_ACCESS_KEY_ID=$${AWS_ACCESS_KEY_ID:-notset} \
--env AWS_DEFAULT_REGION=${AWS_REGION} \
--env AWS_SECRET_ACCESS_KEY=$${AWS_SECRET_ACCESS_KEY:-notset} \
--env IMAGE_TAG=${IMAGE_TAG} \
-p 8888:8888 \
-p 8787:8787 \
--name ${NOTEBOOK_CONTAINER_NAME} \
Expand Down
34 changes: 27 additions & 7 deletions notebooks/demo-aws.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,37 @@
"with open(\"../ecr-details.json\", \"r\") as f:\n",
" ecr_details = json.loads(f.read())\n",
"\n",
"CONTAINER_IMAGE = (\n",
" ecr_details[\"repository\"][\"repositoryUri\"] + \":\" + os.environ[\"DASK_VERSION\"]\n",
")\n",
"print(f\"scheduler and worker image: {CONTAINER_IMAGE}\")"
"IMAGE_REPO = ecr_details[\"repository\"][\"repositoryUri\"]\n",
"IMAGE_TAG = os.environ[\"IMAGE_TAG\"]\n",
"IMAGE_URI = f\"{IMAGE_REPO}:{IMAGE_TAG}\"\n",
"print(f\"scheduler and worker image: {IMAGE_URI}\")"
]
},
{
"cell_type": "markdown",
"id": "harmful-bosnia",
"metadata": {},
"source": [
"Before proceeding, set up your AWS credentials. If you're unsure how to do this, see [the AWS docs](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html)."
"Before proceeding, set up your AWS credentials. If you're unsure how to do this, see [the AWS docs](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html).\n",
"\n",
"Next, determine the CPU architecture of the machine you're running on.\n",
"This project builds single-architecture container images matching the host system, so it's important\n",
"to use the same CPU architecture on AWS Fargate."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4a10d61c-5251-46a7-9f16-bd6eef606a82",
"metadata": {},
"outputs": [],
"source": [
"import platform\n",
"\n",
"if platform.machine().lower() in {\"aarch64\", \"arm64\"}:\n",
" cpu_architecture = \"ARM64\"\n",
"else:\n",
" cpu_architecture = \"X86_64\""
]
},
{
Expand All @@ -85,7 +104,8 @@
"\n",
"n_workers = 3\n",
"cluster = FargateCluster(\n",
" image=CONTAINER_IMAGE,\n",
" image=IMAGE_URI,\n",
" cpu_architecture=cpu_architecture,\n",
" worker_cpu=512,\n",
" worker_mem=4096,\n",
" n_workers=n_workers,\n",
Expand Down Expand Up @@ -300,7 +320,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 59250f3

Please sign in to comment.