pip install https://github.com/abetlen/llama-cpp-python/releases/download/v0.2.55/llama_cpp_python-0.2.55-cp310-cp310-win_amd64.whl
时间: 2024-09-26 21:02:14 浏览: 251
安装Python包通常使用pip工具,但它并不直接支持从GitHub下载的特定版本的wheel文件进行安装。如果要安装像`llama_cpp_python-0.2.55-cp310-cp310-win_amd64.whl`这样的自定义wheel文件,你需要通过命令行手动操作,并确保你的系统环境支持该文件的架构(这里是cp310和win_amd64)。
以下是安装步骤:
1. 打开命令提示符(Windows)或终端(mac/Linux)。
2. 切换到包含wheel文件的目录,例如:
```
cd C:\path\to\your\downloaded\folder
```
或者如果你在Unix-like系统上:
```
cd /path/to/your/downloaded/folder
```
3. 使用pip安装指定的whl文件:
```
pip install llama_cpp_python-0.2.55-cp310-cp310-win_amd64.whl
```
注意检查pip版本是否兼容提供的wheel文件,以及权限是否允许安装。如果有网络连接问题,确保已经下载了完整的文件。
相关问题
E:\SJ\anaconda\envs\roy\python.exe E:\SJ\Llama_finance\finetune_qlora.py WARNING: Failed to find CUDA. bin E:\SJ\anaconda\envs\roy\Lib\site-packages\bitsandbytes\libbitsandbytes_cuda124.dll False ===================================BUG REPORT=================================== ================================================================================ The following directories listed in your path were found to be non-existent: {WindowsPath('E:/SJ/anaconda/envs/roy/bin')} CUDA SETUP: PyTorch settings found: CUDA_VERSION=124, Highest Compute Capability: 8.6. CUDA SETUP: To manually override the PyTorch CUDA version please see:https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md CUDA SETUP: Required library version not found: libbitsandbytes_cuda124.dll. Maybe you need to compile it from source? CUDA SETUP: Defaulting to libbitsandbytes_cpu.dll... ================================================ERROR===================================== CUDA SETUP: CUDA detection failed! Possible reasons: 1. You need to manually override the PyTorch CUDA version. Please see: "https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md 2. CUDA driver not installed 3. CUDA not installed 4. You have multiple conflicting CUDA libraries 5. Required library not pre-compiled for this bitsandbytes release! CUDA SETUP: If you compiled from source, try again with `make CUDA_VERSION=DETECTED_CUDA_VERSION` for example, `make CUDA_VERSION=113`. CUDA SETUP: The CUDA version for the compile might depend on your conda install. Inspect CUDA version via `conda list | grep cuda`. ================================================================================ CUDA SETUP: Something unexpected happened. Please compile from source: git clone https://github.com/TimDettmers/bitsandbytes.git cd bitsandbytes CUDA_VERSION=124 python setup.py install CUDA SETUP: Setup Failed! E:\SJ\anaconda\envs\roy\Lib\site-packages\bitsandbytes\cuda_setup\main.py:17
### 解决方案
当遇到 `CUDA detection failed` 的问题时,通常是因为 PyTorch 和 bitsandbytes 库所依赖的 CUDA 版本与当前安装的 CUDA 驱动或硬件支持的 CUDA 能力之间存在不兼容性。以下是详细的解决方案:
#### 1. **确认硬件支持的 CUDA 能力**
NVIDIA 显卡具有特定的计算能力(Compute Capability),例如引用中的 A800 显卡支持 sm_80 计算能力[^2]。然而,如果当前 PyTorch 安装仅支持较低版本的 CUDA 能力(如 sm_37 至 sm_75),则无法正常运行。
可以通过以下命令查询显卡的支持情况:
```bash
nvidia-smi
```
#### 2. **检查已安装的 CUDA 版本**
通过以下命令验证当前系统的 CUDA 编译工具版本:
```bash
nvcc --version
```
在此案例中,显示的是 CUDA 12.1 工具链[^3]。这表明系统已经安装了一个较新的 CUDA 版本。
#### 3. **调整 PyTorch 的 CUDA 支持版本**
PyTorch 提供了针对不同 CUDA 版本的预编译包。根据引用内容,当前环境中使用的 PyTorch 是基于 CUDA 11.8 构建的[^3]。因此,需要确保系统上的 CUDA 驱动程序至少能够向后兼容到该版本。
可以重新安装适合目标 CUDA 版本的 PyTorch 包。例如,对于 CUDA 11.8,执行如下命令:
```bash
pip install torch==2.1.0+cu118 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
```
#### 4. **处理 bitsandbytes 的 CUDA 不匹配问题**
bitsandbytes 是一个用于优化深度学习训练的库,在某些情况下会提供特定于 CUDA 版本的二进制文件。如果缺少 `libbitsandbytes_cuda124.dll` 文件,则说明当前安装的 bitsandbytes 并未适配系统中的 CUDA 12.1。
建议卸载现有版本并重新安装最新版 bitsandbytes,它可能会自动检测并下载合适的 CUDA 后端:
```bash
pip uninstall bitsandbytes
pip install bitsandbytes
```
或者手动指定对应 CUDA 版本的轮子文件地址,比如适用于 CUDA 12.x 的版本:
```bash
pip install https://github.com/TimDettmers/bitsandbytes/releases/download/nightly-cuda12x/bitsandbytes-0.41.1.post1-cp39-none-win_amd64.whl
```
#### 5. **启用 Apex 或其他混合精度训练工具**
Apex 是另一个常用的混合精度训练加速框架,推荐按照官方指引完成安装过程以增强性能表现[^2]:
```bash
git clone https://github.com/NVIDIA/apex.git
cd apex
pip install -v --disable-pip-version-check --no-cache-dir ./
```
---
### 总结
综合以上措施,应优先校正 PyTorch 所需的 CUDA 版本一致性,并更新至满足需求的新版本 bitsandbytes 库来修复缺失 DLL 导致的功能障碍。最终还需测试整个工作流是否恢复正常运作状态。
(xinference) PS C:\Windows\system32> pip install llama-cpp-python Collecting llama-cpp-python Using cached llama_cpp_python-0.3.7.tar.gz (66.7 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Collecting typing-extensions>=4.5.0 (from llama-cpp-python) Using cached typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB) Collecting numpy>=1.20.0 (from llama-cpp-python) Using cached numpy-2.2.3-cp311-cp311-win_amd64.whl.metadata (60 kB) Collecting diskcache>=5.6.1 (from llama-cpp-python) Using cached diskcache-5.6.3-py3-none-any.whl.metadata (20 kB) Collecting jinja2>=2.11.3 (from llama-cpp-python) Using cached jinja2-3.1.5-py3-none-any.whl.metadata (2.6 kB) Collecting MarkupSafe>=2.0 (from jinja2>=2.11.3->llama-cpp-python) Using cached MarkupSafe-3.0.2-cp311-cp311-win_amd64.whl.metadata (4.1 kB) Using cached diskcache-5.6.3-py3-none-any.whl (45 kB) Using cached jinja2-3.1.5-py3-none-any.whl (134 kB) Using cached numpy-2.2.3-cp311-cp311-win_amd64.whl (12.9 MB) Using cached typing_extensions-4.12.2-py3-none-any.whl (37 kB) Using cached MarkupSafe-3.0.2-cp311-cp311-win_amd64.whl (15 kB) Building wheels for collected packages: llama-cpp-python Building wheel for llama-cpp-python (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for llama-cpp-python (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [306 lines of output] *** scikit-build-core 0.11.0 using CMake 3.31.6 (wheel) *** Configuring CMake... 2025-03-04 00:24:37,103 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None loading initial cache file C:\Users\admin\AppData\Local\Temp\tmphkbm01o4\build\CMakeInit.txt -- Building for: Visual Studio 17 2022 -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.1
### 解决方案概述
当尝试在 Windows 上通过 `pip` 安装 `llama-cpp-python` 时,如果遇到构建 wheel 失败的问题,并显示错误信息 `subprocess-exited-with-error` 和退出码 `1`,这通常意味着编译过程中出现了问题。这类问题可能源于依赖项缺失、环境配置不当或其他兼容性因素。
### 可能的原因分析
此类错误经常发生在基于 C/C++ 的 Python 扩展包安装期间,因为这些扩展需要本地编译工具链支持。对于 `llama-cpp-python` 这样的项目来说,其依赖于特定版本的 CMake 来完成构建过程[^3]。
### 推荐解决方案
#### 方法一:使用预编译二进制文件
最简单的方法之一是从官方渠道获取适用于当前系统的预编译 whl 文件并直接安装:
```bash
pip install https://github.com/your-repo-url/releases/download/vX.Y.Z/llama_cpp_python-X.Y.Z-pyXY-none-win_amd64.whl
```
请注意替换上述 URL 中的具体版本号和架构信息以匹配实际需求。这种方法可以绕过复杂的源码编译流程,从而避免许多潜在的编译器相关问题。
#### 方法二:确保开发工具已正确安装
如果希望继续从源码安装,则需确认 Visual Studio Build Tools 或 MinGW 已经被正确安装并且路径已被加入到系统 PATH 环境变量中。此外还需要保证 scikit-build-core 版本不低于 0.8.2 并且使用的 CMake 至少为 3.28.3 版本。
可以通过以下命令来更新或安装必要的软件包:
```bash
pip install --upgrade pip setuptools wheel cmake scikit-build-core
```
接着再试一次原始的安装指令看看是否能够成功创建轮子文件。
#### 方法三:调整 PIP 配置参数
有时适当修改 PIP 命令的行为也能帮助解决问题。比如增加 `-v` 参数查看更详细的日志输出以便更好地定位问题所在;或者指定临时目录用于存储中间产物防止权限不足引起的问题等。
```bash
pip install llama-cpp-python -v --no-cache-dir --temp-dir ./tmp_build_dir/
```
以上措施有助于排除因缓存污染或是磁盘空间不够等原因造成的失败情况。
### 注意事项
在整个处理过程中应当保持网络连接稳定以免中途下载中断造成不必要的麻烦。另外建议先清理掉之前未成功的构建残留物后再重新开始新的尝试。
阅读全文
相关推荐











