From c3c00a7d7a7dc7a32ff97b27924c08642bf748e0 Mon Sep 17 00:00:00 2001 From: Rkeramati Date: Sat, 25 Oct 2025 13:07:56 -0400 Subject: [PATCH 1/2] cuda dep --- README.md | 56 +++---------------------------------------------- installation.md | 13 ++++++++---- pyproject.toml | 7 ++----- 3 files changed, 14 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 051deb1..3b189f9 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ [![CI](https://github.com/minitorch/minitorch/workflows/CI/badge.svg)](https://github.com/minitorch/minitorch/actions) -* Docs: https://minitorch.github.io/ +* Docs: https://minitorch.github.io -* Overview: https://minitorch.github.io/module4.html +* Overview: https://minitorch.github.io/module4/module4/ Module 4 extends MiniTorch with convolutional neural network operations to build an image recognition system. You'll implement a version of LeNet on MNIST for digit recognition and 1D convolution for NLP sentiment classification: @@ -82,58 +82,8 @@ pre-commit run --all-files - Train a model on Digit classification (MNIST), add logs as `mnist.txt` showing train loss and validation accuracy - Implement Conv1D, Conv2D, and Network classes for both training files -## Testing - -**Module 4 Tasks:** -```bash -pytest -m task4_1 # 1D convolution -pytest -m task4_2 # 2D convolution -pytest -m task4_3 # Pooling operations -pytest -m task4_4 # Advanced NN functions -``` - -**CNN Training:** -```bash -python project/run_mnist_multiclass.py # MNIST digit classification -python project/run_sentiment.py # SST2 sentiment analysis -``` - -**Style Checks:** -```bash -pre-commit run --all-files -ruff check . && pyright -``` - -## CNN Applications - -**MNIST digit classification with CNNs:** -- Convolutional feature extraction -- Spatial pooling for dimension reduction -- Performance comparison with fully-connected networks - -**Expected improvements over fully-connected:** -- Fewer parameters through weight sharing -- Translation invariance for image recognition -- Hierarchical feature learning - -## Module Requirements - -This module requires files from previous assignments, so make sure to pull them over to your new repo. We recommend getting familiar with `tensor.py`, since you might find some of those functions useful for implementing this module. - -Get the required files by running: - -```bash -python sync_previous_module.py -``` - -**Required files from Module 3:** -- All tensor system files and fast operations -- Module framework and autodifferentiation -- Training scripts and datasets ## Resources - **[Installation Guide](installation.md)**: Setup instructions with MNIST -- **[Testing Guide](testing.md)**: CNN testing strategies -- **MiniTorch Docs**: https://minitorch.github.io/ -- **Module 4 Overview**: https://minitorch.github.io/module4.html \ No newline at end of file +- **[Testing Guide](testing.md)**: CNN testing strategies \ No newline at end of file diff --git a/installation.md b/installation.md index b7058ad..7eb307d 100644 --- a/installation.md +++ b/installation.md @@ -1,11 +1,16 @@ # MiniTorch Module 4 Installation -MiniTorch requires Python 3.8 or higher. To check your version of Python, run: +MiniTorch requires Python 3.11. To check your version of Python, run: ```bash >>> python --version ``` +If you don't have Python 3.11, install it before proceeding: +- **Mac**: `brew install python@3.11` +- **Ubuntu/Debian**: `sudo apt install python3.11` +- **Windows**: Download from python.org + We recommend creating a global MiniTorch workspace directory that you will use for all modules: @@ -19,14 +24,14 @@ We highly recommend setting up a *virtual environment*. The virtual environment **Option 1: Anaconda (Recommended)** ```bash ->>> conda create --name minitorch python # Run only once +>>> conda create --name minitorch python=3.11 # Run only once >>> conda activate minitorch ->>> conda install llvmlite # For optimization +>>> conda install llvmlite # For optimization ``` **Option 2: Venv** ```bash ->>> python -m venv venv # Run only once +>>> python3.11 -m venv venv # Run only once (requires Python 3.11) >>> source venv/bin/activate ``` diff --git a/pyproject.toml b/pyproject.toml index 8782b20..74a12e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,11 +6,11 @@ build-backend = "hatchling.build" name = "minitorch" version = "0.5" description = "A minimal deep learning library for educational purposes" -requires-python = ">=3.8" +requires-python = ">=3.8,<3.12" dependencies = [ "colorama==0.4.6", "hypothesis==6.138.2", - "numba>=0.61.2", + "numba-cuda[cu12]>=0.4.0", ## cu12 is for CUDA 12.0 cu13 is for CUDA 13.0 "numpy<2.0", "pytest==8.4.1", "pytest-env==1.1.5", @@ -23,9 +23,6 @@ dev = [ "ruff>=0.8.0", "pyright>=1.1.390", ] -cuda = [ - "numba-cuda[cu12]>=0.4.0", -] extra = [ "python-mnist", "streamlit==1.48.1", From f5579eeaaaaeb2ea74f7ea59ff49a06d095b800e Mon Sep 17 00:00:00 2001 From: Rkeramati Date: Sat, 25 Oct 2025 13:09:55 -0400 Subject: [PATCH 2/2] cuda dep --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 74a12e0..b15dc64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ requires-python = ">=3.8,<3.12" dependencies = [ "colorama==0.4.6", "hypothesis==6.138.2", - "numba-cuda[cu12]>=0.4.0", ## cu12 is for CUDA 12.0 cu13 is for CUDA 13.0 + "numba>=0.61.2", "numpy<2.0", "pytest==8.4.1", "pytest-env==1.1.5", @@ -23,6 +23,9 @@ dev = [ "ruff>=0.8.0", "pyright>=1.1.390", ] +cuda = [ + "numba-cuda[cu12]>=0.4.0", +] extra = [ "python-mnist", "streamlit==1.48.1",