Skip to content

fix(phase-00/07): fix Python 3.12 pip bootstrap and update PyTorch to 2.5.1#250

Open
albertomusumeci wants to merge 1 commit into
rohitg00:mainfrom
albertomusumeci:fix/dockerfile-python312-pip-pytorch
Open

fix(phase-00/07): fix Python 3.12 pip bootstrap and update PyTorch to 2.5.1#250
albertomusumeci wants to merge 1 commit into
rohitg00:mainfrom
albertomusumeci:fix/dockerfile-python312-pip-pytorch

Conversation

@albertomusumeci
Copy link
Copy Markdown

@albertomusumeci albertomusumeci commented Jun 3, 2026

What this PR does

Fixes a broken Dockerfile that fails to build on Ubuntu 22.04 and aligns the lesson doc to match.

Kind of change

  • Fix to an existing lesson

Checklist

  • Code runs without errors with the listed dependencies
  • No comments in code files (docs explain, code is self-explanatory)
  • Tested locally / code output matches what docs/en.md claims

Phase / lesson

Phase 0 · 07-docker-for-ai

Notes for reviewer

The original Dockerfile fails to build on Ubuntu 22.04 with E: Unable to locate package python3.12.

Python 3.12 is not available in the default Ubuntu 22.04 apt repos. The deadsnakes PPA is required to install it.
Additionally, python3-pip on Ubuntu 22.04 binds pip to Python 3.10 (system default), so packages would silently install for the wrong interpreter even if the build succeeded.

Changes:

  • Add deadsnakes PPA to make Python 3.12 available on Ubuntu 22.04
  • Bootstrap pip via get-pip.py called with python3.12
  • Drop python3-pip from apt deps (wrong version, not needed)
  • Update PyTorch 2.3.1 → 2.5.1 (latest stable, cu124 compatible)
  • Update docs/en.md to reflect the corrected Dockerfile

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

PR changed again? Review this PR in Change Stack to compare snapshots and stay oriented.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c998ce0f-5941-4fbc-af19-17b6599f27d8

📥 Commits

Reviewing files that changed from the base of the PR and between 1ff86d0 and 750ffbd.

📒 Files selected for processing (2)
  • phases/00-setup-and-tooling/07-docker-for-ai/code/Dockerfile
  • phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md

📝 Walkthrough

Walkthrough

The Dockerfile and docs are updated to install Python 3.12 from the deadsnakes PPA, bootstrap packaging via python3.12 -m ensurepip --upgrade and upgrade pip/setuptools/wheel, bump PyTorch/cu124 pins to 2.5.1/0.20.1/2.5.1, and set the container CMD to python3.12.

Changes

Python 3.12 and PyTorch Toolchain Upgrade

Layer / File(s) Summary
Python 3.12 bootstrap and PyTorch pin updates
phases/00-setup-and-tooling/07-docker-for-ai/code/Dockerfile
Adds deadsnakes PPA and installs python3.12 plus venv/dev tooling; bootstraps packaging with python3.12 -m ensurepip --upgrade and upgrades pip, setuptools, wheel; bumps torch/torchvision/torchaudio CUDA cu124 pins and switches pip invocations to python3.12 -m pip; updates CMD to python3.12.
Documentation snippet update
phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md
Reworks the Dockerfile snippet to show deadsnakes PPA + Python 3.12 provisioning, python3.12 -m ensurepip bootstrap, updated PyTorch/cu124 version pins, and the CMD ["python3.12"] change.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main changes: fixing Python 3.12 pip bootstrap and updating PyTorch to 2.5.1, which are the primary fixes addressed in this PR.
Description check ✅ Passed The description clearly explains what the PR fixes (broken Dockerfile on Ubuntu 22.04), the root causes, all changes made, and includes a detailed checklist indicating testing was completed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md (3)

60-74: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Replace ASCII diagram blocks and add language tags on fenced blocks.

These sections use plain fenced blocks for diagram-like content and omit language identifiers. Convert these to mermaid (or SVG) and ensure every fenced block has an explicit language tag.

As per coding guidelines, "**/{docs,outputs}/**/*.md: Use Mermaid or SVG only for diagrams. No ASCII / Unicode box-drawing. Every fenced code block needs a language tag."

Also applies to: 123-147

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md` around lines 60 -
74, Replace the ASCII diagram under the "Common container patterns in AI"
section with a proper mermaid (or SVG) diagram and ensure all fenced code blocks
in this file have explicit language tags; specifically convert the
triple-backtick block containing "Dev Container / Training Container / Inference
Container" into a mermaid flowchart (or an inline SVG) and add ```mermaid as the
fence start, and scan the same document for the other ASCII diagram mentioned
(the block around lines referenced in the review) and convert it similarly,
ensuring every fenced block includes a language identifier.

1-16: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add required docs/en.md frontmatter block.

This file is missing the required frontmatter (Title, one-line hook, Type, Languages, Prerequisites, Time estimate, and 4–6 Learning Objectives).

As per coding guidelines, "**/docs/en.md: Include frontmatter in docs/en.md with fields: Title, one-line hook, Type (Learn|Build|Reference), Languages (matching main.* files), Prerequisites, Time estimate, and 4-6 Learning Objectives bullet points."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md` around lines 1 - 16,
Add a YAML frontmatter block to the top of docs/en.md containing Title, a
one-line hook, Type (Learn|Build|Reference), Languages (matching the file’s
Languages line), Prerequisites, Time estimate, and 4–6 Learning Objectives;
include the existing items already listed (GPU Docker image with CUDA/PyTorch,
mounting volumes, NVIDIA Container Toolkit, Docker Compose orchestration) as the
Learning Objectives and ensure the Time/Type/Languages/Prerequisites fields
mirror the content below so the file has a complete frontmatter header.

19-39: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update stale PyTorch version references to match the Dockerfile.

Narrative and diagram text still references PyTorch 2.3/2.3.1, but the Dockerfile now pins 2.5.1. Please align these to avoid learner confusion.

Also applies to: 138-141

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md` around lines 19 -
39, Update all stale PyTorch version mentions ("PyTorch 2.3" and "PyTorch
2.3.1") in the narrative and the Mermaid diagram nodes (e.g., A1, A2, A3, B1,
B2, B3) to match the Dockerfile pinned version (PyTorch 2.5.1), and make the
same replacement for the additional occurrences referred to (lines noted as
138-141 in the review). Ensure both plain text and diagram labels show "PyTorch
2.5.1" so the documentation and visual example are consistent with the
Dockerfile.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@phases/00-setup-and-tooling/07-docker-for-ai/code/Dockerfile`:
- Around line 20-21: The Dockerfile currently pipes the remote get-pip.py
directly into the interpreter (the RUN line containing "curl -sS
https://bootstrap.pypa.io/get-pip.py | python3.12"), which executes unverified
network code; instead, update that RUN step to download get-pip.py to a file
(use curl -fSL -o), verify its SHA256 checksum against a pinned value, fail the
build if the checksum mismatches, and only then execute it with python3.12 (or
prefer python3.12 -m ensurepip if you want to avoid remote scripts); reference
the RUN line with the get-pip.py download/verification and the subsequent
python3.12 execution to implement the changes.

---

Outside diff comments:
In `@phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md`:
- Around line 60-74: Replace the ASCII diagram under the "Common container
patterns in AI" section with a proper mermaid (or SVG) diagram and ensure all
fenced code blocks in this file have explicit language tags; specifically
convert the triple-backtick block containing "Dev Container / Training Container
/ Inference Container" into a mermaid flowchart (or an inline SVG) and add
```mermaid as the fence start, and scan the same document for the other ASCII
diagram mentioned (the block around lines referenced in the review) and convert
it similarly, ensuring every fenced block includes a language identifier.
- Around line 1-16: Add a YAML frontmatter block to the top of docs/en.md
containing Title, a one-line hook, Type (Learn|Build|Reference), Languages
(matching the file’s Languages line), Prerequisites, Time estimate, and 4–6
Learning Objectives; include the existing items already listed (GPU Docker image
with CUDA/PyTorch, mounting volumes, NVIDIA Container Toolkit, Docker Compose
orchestration) as the Learning Objectives and ensure the
Time/Type/Languages/Prerequisites fields mirror the content below so the file
has a complete frontmatter header.
- Around line 19-39: Update all stale PyTorch version mentions ("PyTorch 2.3"
and "PyTorch 2.3.1") in the narrative and the Mermaid diagram nodes (e.g., A1,
A2, A3, B1, B2, B3) to match the Dockerfile pinned version (PyTorch 2.5.1), and
make the same replacement for the additional occurrences referred to (lines
noted as 138-141 in the review). Ensure both plain text and diagram labels show
"PyTorch 2.5.1" so the documentation and visual example are consistent with the
Dockerfile.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 413bc385-d235-4ca2-a2e9-e61492fd7071

📥 Commits

Reviewing files that changed from the base of the PR and between 44b9b14 and 1ff86d0.

📒 Files selected for processing (2)
  • phases/00-setup-and-tooling/07-docker-for-ai/code/Dockerfile
  • phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md

Comment thread phases/00-setup-and-tooling/07-docker-for-ai/code/Dockerfile Outdated
@albertomusumeci albertomusumeci force-pushed the fix/dockerfile-python312-pip-pytorch branch from 1ff86d0 to 750ffbd Compare June 6, 2026 09:05
@albertomusumeci
Copy link
Copy Markdown
Author

albertomusumeci commented Jun 6, 2026

Updated Dockerfile (and en.md) to use python3.12 -m ensurepip instead of piping get-pip.py, addressing the security concern raised by CodeRabbit. No remote code execution involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant