Skip to content

feat: add CUDA availability check with helpful error message#176

Open
tykoo-chen wants to merge 1 commit intokarpathy:masterfrom
tykoo-chen:feat/gpu-availability-check
Open

feat: add CUDA availability check with helpful error message#176
tykoo-chen wants to merge 1 commit intokarpathy:masterfrom
tykoo-chen:feat/gpu-availability-check

Conversation

@tykoo-chen
Copy link

Problem

Currently train.py assumes CUDA is available and will crash with a cryptic error if no GPU is detected:

  • torch.cuda.get_device_capability() throws an exception
  • Users on Mac or without NVIDIA GPUs get confusing error messages

Solution

Add an early check for CUDA availability before any CUDA operations, with a helpful error message that:

  1. Clearly states an NVIDIA GPU is required
  2. Points Mac users to the MLX forks listed in README
  3. Suggests checking CUDA drivers on Windows/Linux

Code Change

# Verify CUDA is available before proceeding
if not torch.cuda.is_available():
    print("Error: No CUDA GPU detected. This script requires an NVIDIA GPU.")
    print("If you're on Mac, see the MLX forks listed in README.md")
    print("If you're on Windows/Linux, ensure CUDA drivers are installed.")
    exit(1)

Benefits

  • Better user experience for people trying the repo on unsupported hardware
  • Faster path to the correct solution (forks for Mac, driver installation for Windows/Linux)

Currently train.py assumes CUDA is available and will crash with a
cryptic error if no GPU is detected. This adds an early check with
a helpful message pointing users to:
- MLX forks for Mac users
- CUDA driver installation for Windows/Linux users
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