请求安装兼容torch 1.9.0+cu111的peft与accelerate
解决PyTorch 1.9.0+cu111与PEFT、Accelerate的兼容安装问题
问题背景
原本计划使用以下命令安装Hugging Face相关库:
!pip install -q git+https://github.com/huggingface/transformers.git !pip install -q git+https://github.com/huggingface/peft.git !pip install -q git+https://github.com/huggingface/accelerate.git
但当前环境中PyTorch版本为1.9.0+cu111,最新版本的PEFT和Accelerate存在兼容性限制:
- Accelerate 0.27.0.dev0要求
torch>=1.10.0,与当前PyTorch版本不兼容; - PEFT 0.7.2.dev0要求
torch>=1.13.0,与当前PyTorch版本不兼容。
当前环境信息
执行以下代码查看环境:
import torch print("torch.__version__", torch.__version__) print("torch.version.cuda", torch.version.cuda) print("torch.__config__", torch.__config__.show()) print("torch.cuda.device_count", torch.cuda.device_count()) # Print the number of CUDA devices import torchvision print("torchvision", torchvision.__version__)
输出结果:
torch.__version__ 1.9.0+cu111 torch.version.cuda 11.1 torch.__config__ PyTorch built with: - C++ Version: 199711 - MSVC 192829337 - Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications - Intel(R) MKL-DNN v2.1.2 (Git Hash 98be7e8afa711dc9b66c8ff3504129cb82013cdb) - OpenMP 2019 - CPU capability usage: AVX2 - CUDA Runtime 11.1 - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37 - CuDNN 8.0.5 - Magma 2.5.4 - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.1, CUDNN_VERSION=8.0.5, CXX_COMPILER=C:/w/b/windows/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -IC:/w/b/windows/mkl/include -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.9.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, torch.cuda.device_count 1 torchvision 0.10.0+cu111
解决方案
方法1:安装兼容的历史版本
选择支持PyTorch 1.9.0的最高稳定版本进行安装,确保依赖匹配:
- Transformers:4.28.1(与PEFT 0.4.0、Accelerate 0.16.0兼容)
- PEFT:0.4.0(要求torch>=1.9.0)
- Accelerate:0.16.0(要求torch>=1.9.0)
安装命令:
!pip install -q transformers==4.28.1 !pip install -q peft==0.4.0 !pip install -q accelerate==0.16.0
方法2:跳过依赖检查(临时测试用)
如果仅需临时测试功能,可添加参数跳过版本检查,但可能导致运行时错误:
!pip install -q git+https://github.com/huggingface/transformers.git --force-reinstall --no-deps !pip install -q git+https://github.com/huggingface/peft.git --force-reinstall --no-deps !pip install -q git+https://github.com/huggingface/accelerate.git --force-reinstall --no-deps
注意:此方法可能引发未知兼容性问题,不建议用于生产环境。
方法3:升级PyTorch(长期推荐方案)
若环境允许,升级PyTorch到兼容最新PEFT和Accelerate的版本,比如适配CUDA 11.1的PyTorch 1.13.0+cu111:
!pip install torch==1.13.0+cu111 torchvision==0.14.0+cu111 --extra-index-url https://download.pytorch.org/whl/cu111
升级完成后,即可使用原命令安装最新版本的PEFT和Accelerate。
内容的提问来源于stack exchange,提问作者yts61
相关产品推荐
相关产品推荐

