A console/terminal check of whether PyTorch can see the CUDA GPUs on Windows 11 and Ubuntu Linux 24.04. It prints the torch version, whether CUDA is available, the number of devices, the current device index, and the name of every device — the quickest way to confirm that a machine is ready for GPU training before you start a real project.
[Folder Structure]
- CLAUDE.md / AGENT.md: program specification (identical content).
- CHANGELOG.md: change log.
- copyright.txt: copyright notice.
- src/: the test script, the launcher scripts, and this document.
- venv/: Python virtual environment, created by step 1.
[Prerequisites]
- Operating system: Windows 11 or Ubuntu Linux 24.04.
- Python 3 and pip.
- Python packages: torch (installed automatically by step 1).
- For a GPU result: an NVIDIA graphics card with an up-to-date driver. The script also runs on a CPU-only machine and simply reports that no device was found.
- Internet is needed the first time, to download torch.
[Instructions]
Step 1: Create the virtual environment
Create the virtual environment and install torch. This is a torch project, so on a GPU machine use the 01_venv_create_gpu script, which installs the CUDA 12.8 build — the plain 01_venv_create script installs the CPU build and will always report that CUDA is unavailable.
Windows 11, GPU:
src\01_venv_create_gpu.bat
Windows 11, CPU:
src\01_venv_create.bat
Ubuntu Linux 24.04, GPU:
bash src/01_venv_create_gpu.sh
Ubuntu Linux 24.04, CPU:
bash src/01_venv_create.sh
Step 2: Activate the virtual environment
Activate the environment in the current shell. On Linux you must source the script so the activation stays in effect after it finishes.
Windows 11:
src\02_venv_activate.bat
Ubuntu Linux 24.04:
source src/02_venv_activate.sh
Step 3: Run the CUDA check
Run the check. The report lists the torch version, whether CUDA is available, how many devices there are, the index of the current device, and each device name.
Windows 11:
src\03_cuda_test.bat
Ubuntu Linux 24.04:
bash src/03_cuda_test.sh
Step 4: Remove the virtual environment
When you are finished, delete the venv/ folder to free up disk space. Re-run step 1 whenever you need the environment again.
Windows 11:
src\99_venv_clear.bat
Ubuntu Linux 24.04:
bash src/99_venv_clear.sh
[Reading the Report]
- On a CPU-only machine, or with a CPU-only torch build, the script reports 0 devices and exits cleanly — the device query is guarded, so it never crashes.
- CUDA unavailable while an NVIDIA card is installed almost always means the CPU build of torch was installed: re-create the environment with 01_venv_create_gpu.
- The device count is the number of GPUs torch can use; the current device is the index it will pick by default, which is 0 unless the program changes it.
- The CUDA version reported by torch is the one the torch build was compiled against, and does not have to match the version shown by nvidia-smi — the driver only needs to be new enough.
This SDK is built in AppForAI - AI Dev Tools.
Purchase license separately: USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.