You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 10下运行h2oGPT加载Falcon LLM的CUDA错误求助

解决Windows下h2oGPT加载Falcon 7B 8-bit模型时的bitsandbytes CUDA错误

问题场景

从h2oai/h2ogpt仓库获取代码后,执行以下命令加载Falcon 7B模型:

python generate.py --base_model=h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3 --score_model=None --prompt_type=human_bot --cli=True --load_8bit=True

持续出现以下核心错误:

argument of type 'WindowsPath' is not iterable
CUDA SETUP: Problem: The main issue seems to be that the main CUDA runtime library was not detected.

已配置环境变量CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin,但问题未解决。

解决方案

1. 安装Windows适配版bitsandbytes

默认bitsandbytes包仅适配Linux系统,Windows需安装专门分支:

  • 卸载原有包:
    pip uninstall bitsandbytes -y
    
  • 安装Windows兼容版本:
    pip install bitsandbytes-windows
    

2. 匹配PyTorch与CUDA版本

错误日志显示PyTorch检测到的CUDA版本为11.7,但本地安装的是CUDA 12.2,版本不匹配会导致检测失败:

  • 检查当前PyTorch绑定的CUDA版本:
    python -c "import torch; print(torch.version.cuda)"
    
  • 若输出为11.7,可选择:
    • 安装CUDA 11.7版本,与PyTorch保持一致;
    • 重新安装适配CUDA 12.x的PyTorch:
      pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
      
      (注:PyTorch官方cu121包兼容CUDA 12.1及12.2版本)

3. 强制bitsandbytes使用指定CUDA版本

通过环境变量指定bitsandbytes加载的CUDA二进制文件版本:

  • 终端临时设置:
    set BITSANDBYTES_CUDA_VERSION=122
    
  • 永久生效:在系统环境变量中添加BITSANDBYTES_CUDA_VERSION,值设为122

4. 修复WindowsPath迭代bug(可选)

若仍出现WindowsPath相关错误,手动修改bitsandbytes代码:

  • 找到文件:C:\Users\BahugBilat\AppData\Local\Programs\Python\Python311\Lib\site-packages\bitsandbytes\cuda_setup\main.py
  • 搜索路径处理代码,将WindowsPath对象转为字符串,例如把path in paths改为str(path) in paths

验证步骤

  1. 关闭当前终端,重新打开确保环境变量生效;
  2. 运行nvcc --version确认CUDA版本显示正确;
  3. 再次执行原generate.py命令测试模型加载。

内容的提问来源于stack exchange,提问作者user22374560

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 23:54:56