Most problems encountered when setting up or running SSRL-ECG fall into one of a handful of categories: an installation shortcut that skips editable-mode setup, a tensor-shape assumption that differs between a single sample and a full batch, or a GPU configuration that silently falls back to CPU. This page collects every known issue and its verified fix, drawn directly from the project’s source code and README.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Tumo505/SSL-for-ECG-classification/llms.txt
Use this file to discover all available pages before exploring further.
There is a critical distinction between these two installation commands:
Always use
| Command | What it does |
|---|---|
pip install -r requirements.txt | Installs Python dependencies only. The ssrl_ecg package itself is not registered with Python’s import system. |
pip install -e . | Installs dependencies and registers ssrl_ecg as an editable package, making import ssrl_ecg work from any working directory. |
pip install -e .. Running requirements.txt alone is the root cause of the majority of ModuleNotFoundError reports.Common Issues
ModuleNotFoundError: No module named 'ssrl_ecg'
ModuleNotFoundError: No module named 'ssrl_ecg'
SymptomThis error appears when you try to run any training or evaluation script without having installed the package in editable mode.Root causeRunning The
pip install -r requirements.txt installs third-party dependencies (PyTorch, NumPy, etc.) but does not register the local ssrl_ecg package on the Python path.FixFrom the repository root, run:- Linux / macOS
- Windows (PowerShell)
-e flag installs the package in editable (development) mode. Python resolves imports directly from the src/ directory, so any local edits take effect immediately without reinstalling.Verify the fixTensor shape errors in augmentations
Tensor shape errors in augmentations
Symptomor similar shape mismatches when applying
ECGAugmentations.Root causeECG data arrives in two shapes depending on context:- Single sample (e.g., during inference or manual testing):
(channels, time)— a 2D tensor. - Batch (during training):
(batch, channels, time)— a 3D tensor.
ECGAugmentations class automatically detects input dimensionality and handles both cases:- 2D input
(channels, time)→ internally promoted to(1, channels, time), augmented, then squeezed back to(channels, time). - 3D input
(batch, channels, time)→ processed as-is.
.pyc file:CUDA out of memory (OOM)
CUDA out of memory (OOM)
SymptomRoot causeThe default batch sizes (
--batch-size 128 for SimCLR, --batch-size 256 for BYOL) are tuned for GPUs with ≥ 16 GB VRAM. Smaller cards will OOM during the forward pass.FixReduce the batch size. Start at 64 and halve again if necessary:- SimCLR
- BYOL
- Supervised / Fine-tune
choose_device() also pre-allocates 95 % of available GPU memory and clears the cache before training begins (torch.cuda.empty_cache()), which helps avoid fragmentation-related OOM on repeated short runs in the same process.Slow training / CPU fallback
Slow training / CPU fallback
SymptomTraining appears to run but is extremely slow — epochs take minutes instead of seconds, or Common causes and fixes
Expected If you see the CPU fallback message instead, address the CUDA installation before training.
choose_device() prints [WARNING] No CUDA-capable GPU detected!.DiagnosisRun both checks before starting any long experiment:| Cause | Fix |
|---|---|
| CUDA toolkit not installed or wrong version | Install CUDA matching your PyTorch build (torch.__version__ shows the expected CUDA suffix, e.g., +cu121) |
| PyTorch CPU-only wheel installed | Reinstall with the correct CUDA wheel from pytorch.org |
| GPU in use by another process | Check nvidia-smi for competing processes and free VRAM |
| Virtual environment mismatch | Ensure the venv with pip install -e . is active |
choose_device() output when GPU is detectedDataset FileNotFoundError
Dataset FileNotFoundError
SymptomRoot causeThe data loader expects a specific folder structure under the path passed to Fix
--data-root. If the PTB-XL archive was extracted to a different location, or the CSV metadata files are missing, the dataset class cannot initialise.Required folder layout-
Download PTB-XL from PhysioNet and extract it so that
ptbxl_database.csvlives directly inside the folder you pass to--data-root. -
Pass the correct path explicitly:
-
Verify the structure before running training:
A successful run prints class distribution and split statistics, confirming the dataset is readable.
Checkpoint loading errors — wrong key
Checkpoint loading errors — wrong key
SymptomorRoot causeSSRL-ECG uses two different checkpoint schemas depending on the training stage:
Passing an SSL checkpoint to a script that expects a classifier checkpoint (or vice versa) raises a key error.FixInspect the checkpoint before loading:Then load with the correct key:
| Script | Saved key | Contains |
|---|---|---|
train_ssl_simclr.py, train_ssl_byol.py | encoder | Encoder weights only (no projection head) |
train_supervised.py, train_finetune.py, train_supervised_multiseed.py | model | Full ECGClassifier state dict |
The fine-tuning script (
train_finetune.py) specifically reads the encoder
key from the SSL checkpoint and wraps it in a new ECGClassifier — it does
not expect a model key at the input stage.Windows vs Linux command syntax
Windows vs Linux command syntax
SymptomMulti-line commands from the README fail on Windows with a parse error, or commands written for PowerShell fail on Linux/macOS.Root causeThe two platforms use different characters to continue a command across multiple lines:
Examples
| Platform | Line-continuation character | Example |
|---|---|---|
| Linux / macOS (bash) | \ (backslash) | python script.py \ |
| Windows (PowerShell) | ` (backtick) | python script.py ` |
- Linux / macOS (bash)
- Windows (PowerShell)
- Single line (any platform)
Quick-Reference Diagnostic Commands
Check package installation
ModuleNotFoundError, run pip install -e ..Verify CUDA availability
True before starting any GPU training.