If you want to uninstall all packages with "torch" in the name via a single command (using pip freeze and grep):
User
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 - I'm going to install this to fix my error, do you think it will?
Assistant
Installing PyTorch with the CUDA 12.1 (cu121) wheels using:
(whisper) C:\AI\Whisper>python app.py
Traceback (most recent call last):
File "C:\AI\Whisper\app.py", line 15, in
import spaces
ModuleNotFoundError: No module named 'spaces'
(whisper) C:\AI\Whisper>python app.py
'pip' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
File "C:\AI\Whisper\app.py", line 23, in
from transformers import pipeline
ModuleNotFoundError: No module named 'transformers'
(whisper) C:\AI\Whisper>python app.py
'pip' is not recognized as an internal or external command,
operable program or batch file.
config.json: 100%|████████████████████████████████████████████████████████████████| 1.26k/1.26k [00:00<00:00, 1.26MB/s]
model.safetensors: 100%|██████████████████████████████████████████████████████████| 1.62G/1.62G [00:59<00:00, 27.3MB/s]
Traceback (most recent call last):
File "C:\AI\Whisper\app.py", line 26, in
pipe = pipeline(
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\pipelines_init_.py", line 942, in pipeline
framework, model = infer_framework_load_model(
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\pipelines\base.py", line 291, in infer_framework_load_model
model = model_class.from_pretrained(model, **kwargs)
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\models\auto\auto_factory.py", line 571, in from_pretrained
return model_class.from_pretrained(
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\modeling_utils.py", line 279, in _wrapper
return func(*args, **kwargs)
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\modeling_utils.py", line 4336, in from_pretrained
config = cls._autoset_attn_implementation(
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\modeling_utils.py", line 2109, in _autoset_attn_implementation
cls._check_and_enable_flash_attn_2(
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\modeling_utils.py", line 2252, in _check_and_enable_flash_attn_2
raise ImportError(f"{preface} the package flash_attn seems to be not installed. {install_message}")
ImportError: FlashAttention2 has been toggled on, but it cannot be used due to the following error: the package flash_attn seems to be not installed. Please refer to the documentation of https://huggingface.co/docs/transformers/perf_infer_gpu_one#flashattention-2 to install Flash Attention 2.
(whisper) C:\AI\Whisper>python app.py
'pip' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\utils\import_utils.py", line 1967, in get_module
return importlib.import_module("." + module_name, self.name)
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\importlib_init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in call_with_frames_removed
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\pipelines_init.py", line 49, in
from .audio_classification import AudioClassificationPipeline
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\pipelines\audio_classification.py", line 21, in
from .base import Pipeline, build_pipeline_init_args
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\pipelines\base.py", line 69, in
from ..modeling_utils import PreTrainedModel
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\modeling_utils.py", line 62, in
from .integrations.flash_attention import flash_attention_forward
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\integrations\flash_attention.py", line 5, in
from ..modeling_flash_attention_utils import flash_attention_forward, flash_attn_supports_top_left_mask
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\modeling_flash_attention_utils.py", line 36, in
from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\flash_attn_init.py", line 3, in
from flash_attn.flash_attn_interface import (
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\flash_attn\flash_attn_interface.py", line 10, in
import flash_attn_2_cuda as flash_attn_cuda
ImportError: DLL load failed while importing flash_attn_2_cuda: The specified procedure could not be found.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\AI\Whisper\app.py", line 23, in
from transformers import pipeline
File "", line 1075, in _handle_fromlist
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\utils\import_utils.py", line 1955, in getattr
module = self._get_module(self._class_to_module[name])
File "C:\Users\DjZaN\miniconda3\envs\whisper\lib\site-packages\transformers\utils\import_utils.py", line 1969, in _get_module
raise RuntimeError(
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
DLL load failed while importing flash_attn_2_cuda: The specified procedure could not be found.
You installed FlashAttention2 via a precompiled wheel for Windows, but the error:
code
ImportError: DLL load failed while importing flash_attn_2_cuda: The specified procedure could not be found.
indicates that the underlying flash_attn_2_cuda CUDA extension failed to load properly. This usually points to one or more of the following:
Common Causes and Fixes for this Error:
1. CUDA Version Mismatch or Incompatibility
Your installed PyTorch is built for CUDA 12.6 (torch-2.7.0+cu126), and your NVIDIA system driver and nvcc show CUDA 12.4.
FlashAttention extensions generally require the CUDA toolkit and the GPU driver versions to be compatible.
Solution: Update your NVIDIA GPU drivers to the latest version to ensure compatibility with CUDA 12.6.
2. Missing or Incorrect Microsoft Visual C++ Redistributable DLLs
If it's already installed, try repairing or reinstalling it.
3. CUDA Toolkit Not Properly Installed or Missing PATH Entries
The CUDA DLLs (cudart64_*.dll and others) must be in PATH.
Since nvcc --version works, your CUDA path might be fine, but still ensure:
Your environment variable PATH includes %CUDA_PATH%\bin and %CUDA_PATH%\lib\x64.
%CUDA_PATH% is usually something like C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4 (adjust based on your install)
4. Incorrect FlashAttention Wheel Version for Your PyTorch or CUDA
The pre-built FlashAttention wheel you installed is for PyTorch 2.7.0 and seems compatible with your Python 3.10 arch.
However, the CUDA version might still be an issue (you have CUDA 12.4 installed but wheel might expect CUDA 12.6).
Try: either using a FlashAttention wheel built specifically for CUDA 12.4 or, better, upgrade your CUDA to 12.6.
5. Python Environment Corruption
Occasionally the pip command not being recognized (even in the activated environment) hints at potential environment PATH issues.
You also see 'pip' is not recognized as an internal or external command while running python app.py; this means the script or environment might be calling pip incorrectly—or your environment's PATH is missing pip.
Solution: To fix pip recognition in the active conda env, try running:
code
python -m pip install --upgrade pip
This ensures pip is accessible as a module and often fixes path issues.
Additional Suggestions to Try
Upgrade GPU Drivers and CUDA Toolkit:
Download and install the latest NVIDIA drivers from the official site.
Download & install CUDA Toolkit 12.6 to match PyTorch’s CUDA version.
Check nvcc and nvidia-smi versions:
code
nvcc --version
nvidia-smi
Make sure nvidia-smi driver version matches or exceeds CUDA 12.6 compatibility.
Reinstall FlashAttention Matching CUDA Version:
Use a FlashAttention wheel specifically built for CUDA 12.6 if possible.
The error stems from FlashAttention2. Disable it by setting the environment variable before running your app:
On Windows CMD:
code
set TRANSFORMERS_NO_FLASH_ATTENTION=1
python app.py
Or inside your Python script before import:
python
import os
os.environ["TRANSFORMERS_NO_FLASH_ATTENTION"] = "1"
from transformers import pipeline
# ...
If this works, flash attention is the confirmed cause.
Check for FlashAttention Extension File and Dependencies:
In your environment, check if flash_attn_2_cuda.cp310-win_amd64.pyd or similar exists under the installed flash_attn package directory.
Use dependency walker tools (like Dependencies) to inspect it and find which DLL is missing.
Make sure you run the script in the activated conda environment, and that all packages are installed there.
Summary for your case
Your system CUDA is 12.4, but PyTorch and flash-attn wheel expect CUDA 12.6+.
Upgrade your NVIDIA GPU drivers and CUDA Toolkit from 12.4 to 12.6 (or a version compatible with your PyTorch + flash-attn).
Ensure the Visual C++ redistributable is installed.
Optionally disable flash_attention temporarily to test your app.
Fix pip command recognition by upgrading pip via python -m pip install --upgrade pip.
If after these steps the issue persists, consider opening an issue on the flash-attention GitHub repos or the huggingface transformers repo with details about your environment, CUDA version, PyTorch version, and exact error logs.
If you want, I can help you with commands to check your current driver, upgrade steps, or disabling flash-attention in your app script.
Currently, PyTorch official binaries are released targeting CUDA versions such as 11.7, 11.8, 12.1, 12.2, and 12.6, but there is no official PyTorch binary specifically built for CUDA 12.4.
Your NVIDIA nvcc --version shows CUDA 12.4 installed, but PyTorch binaries built for CUDA 12.x (like 12.6) typically work fine with CUDA minor versions close by, as long as your GPU driver is compatible.
Recommended approach:
1. Update your CUDA Toolkit to 12.6 (recommended)
Since PyTorch provides official binaries for CUDA 12.6 (with +cu126 tag), the easiest solution is to upgrade your CUDA Toolkit from 12.4 to 12.6.
The CUDA minor versions (12.4 → 12.6) are backward-compatible at the driver level if you install matching or newer drivers.
may or may not fix your specific flash_attn_2_cuda DLL load error.
Explanation:
Your current system CUDA toolkit version is 12.4.
PyTorch official wheels are available for CUDA 12.1 and 12.6, but not for 12.4.
The cu121 wheel targets CUDA 12.1 but often works fine with CUDA minor versions near 12.1 (such as 12.4), provided your NVIDIA driver is new enough to support runtime compatibility.
Your current error specifically involves the FlashAttention2 CUDA extension, which is a separate native CUDA-accelerated library outside core PyTorch.
The FlashAttention2 package and the PyTorch CUDA version must be compatible with your installed CUDA driver and runtime.
Installing the cu121 version of PyTorch might make PyTorch itself more compatible with your CUDA 12.4 setup.
However, the FlashAttention package still needs to be compatible with your environment, and the error you got (DLL load failed) often comes from driver/toolkit mismatch or missing dependencies in the FlashAttention native extensions.
What should you do?
Try installing the cu121 PyTorch version and test if your app works without errors: