当前位置: 首页 > news >正文

安装vllm的艰苦过程

历时两天,终于把vllm库安装好了,简单地记录了一下过程。结果见下图:

首先是,一开始在安装的时候,可能会遇到gcc版本的问题。假如你的版本是7.5.0的,那么就需要注意了,这个gcc就要升级一下。下面是免sudo的升级办法:

 conda install -c conda-forge gxx=11.2.0conda install -c conda-forge gcc=11.2.0

然后就可以放心地安装vllm了,执行

pip install -U --extra-index-url https://download.pytorch.org/whl/cu121 vllm --pre

为什么呢?如果你不这样执行,直接pip install vllm,可能会出现如下的报错:

分享

INFO: pip is looking at multiple versions of vllm to determine which version is compatible with other requirements. This could take a while. ERROR: Ignored the following versions that require a different python version: 0.52.0 Requires-Python >=3.6,<3.9; 0.52.0rc3 Requires-Python >=3.6,<3.9; 0.53.0 Requires-Python >=3.6,<3.10; 0.53.0rc1.post1 Requires-Python >=3.6,<3.10; 0.53.0rc2 Requires-Python >=3.6,<3.10; 0.53.0rc3 Requires-Python >=3.6,<3.10; 0.53.1 Requires-Python >=3.6,<3.10; 0.54.0 Requires-Python >=3.7,<3.10; 0.54.0rc2 Requires-Python >=3.7,<3.10; 0.54.0rc3 Requires-Python >=3.7,<3.10; 0.54.1 Requires-Python >=3.7,<3.10; 1.16.0 Requires-Python >=3.11; 1.16.0rc1 Requires-Python >=3.11; 1.16.0rc2 Requires-Python >=3.11; 1.16.1 Requires-Python >=3.11; 1.16.2 Requires-Python >=3.11; 1.6.2 Requires-Python >=3.7,<3.10; 1.6.3 Requires-Python >=3.7,<3.10; 1.7.0 Requires-Python >=3.7,<3.10; 1.7.1 Requires-Python >=3.7,<3.10 ERROR: Could not find a version that satisfies the requirement torch==2.7.1 (from vllm) (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.6.0) ERROR: No matching distribution found for torch==2.7.1

它的意思就是说,你要确保torch的版本是2.7.1,但实际上用pip安装torch==2.7.1的时候,是找不到这个版本的。所以你就需要安装更低版本的。

不要尝试装torch 2.7.1——它目前就不存在!

torch 2.7.1目前根本不存在,而vLLM 0.10.x的setup.py却硬写死了这两个版本,于是pip永远找不到,直接ResolutionImpossible。这是vLLM官方打包bug,不是你用错命令。大模型给出的解决方案是:直接用官方nightly(已修复依赖)官方仓库2025-08-30之后已把依赖改成torch>=2.5.0,<2.6(用 2.5.1)并推送了nightly轮子,一条命令就能装(也就是上面带有'--pre'后缀的那一条命令)。

后面我又遇到了报错(比较长,不想看可以不看):

FAILED: [code=1] CMakeFiles/_zmq.dir/_src/_zmq.c.o
      /share/home/xxxx/miniconda3/envs/py3x/bin/gcc  -pthread -B /share/home/xxxxx/miniconda3/envs/py3x/compiler_compat -DZMQ_STATIC -DZMQ_STATIC=1 -D_zmq_EXPORTS -I/tmp/tmpe4fb6121/build/bundled/include -I/tmp/pip-install-rp8eg1yg/pyzmq_af41d5fbd54846de86c9f864e683968f/zmq/utils -I/tmp/tmpe4fb6121/build/_deps/bundled_libzmq-src/include -I/tmp/tmpe4fb6121/build/_deps/bundled_libzmq-build -isystem /share/home/xxxxx/miniconda3/envs/py3x/include/python3.10 -O3 -DNDEBUG -fPIC -MD -MT CMakeFiles/_zmq.dir/_src/_zmq.c.o -MF CMakeFiles/_zmq.dir/_src/_zmq.c.o.d -o CMakeFiles/_zmq.dir/_src/_zmq.c.o -c /tmp/tmpe4fb6121/build/_src/_zmq.c
      In file included from /tmp/tmpe4fb6121/build/_src/_zmq.c:11:
      /share/homexxxx/miniconda3/envs/py3x/include/python3.10/Python.h:44:10: fatal error: crypt.h: No such file or directory
         44 | #include <crypt.h>
            |          ^~~~~~~~~
      compilation terminated.
      ninja: build stopped: subcommand failed.
      
      *** CMake build failed
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyzmq
  Building wheel for sentencepiece (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for sentencepiece (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [98 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-310/sentencepiece
      copying src/sentencepiece/__init__.py -> build/lib.linux-x86_64-cpython-310/sentencepiece
      copying src/sentencepiece/_version.py -> build/lib.linux-x86_64-cpython-310/sentencepiece
      copying src/sentencepiece/sentencepiece_model_pb2.py -> build/lib.linux-x86_64-cpython-310/sentencepiece
      copying src/sentencepiece/sentencepiece_pb2.py -> build/lib.linux-x86_64-cpython-310/sentencepiece
      running egg_info
      writing src/sentencepiece.egg-info/PKG-INFO
      writing dependency_links to src/sentencepiece.egg-info/dependency_links.txt
      writing requirements to src/sentencepiece.egg-info/requires.txt
      writing top-level names to src/sentencepiece.egg-info/top_level.txt
      reading manifest file 'src/sentencepiece.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'src/sentencepiece.egg-info/SOURCES.txt'
      copying src/sentencepiece/sentencepiece.i -> build/lib.linux-x86_64-cpython-310/sentencepiece
      copying src/sentencepiece/sentencepiece_wrap.cxx -> build/lib.linux-x86_64-cpython-310/sentencepiece
      creating build/lib.linux-x86_64-cpython-310/sentencepiece/package_data
      copying src/sentencepiece/package_data/nfkc.bin -> build/lib.linux-x86_64-cpython-310/sentencepiece/package_data
      copying src/sentencepiece/package_data/nfkc_cf.bin -> build/lib.linux-x86_64-cpython-310/sentencepiece/package_data
      copying src/sentencepiece/package_data/nmt_nfkc.bin -> build/lib.linux-x86_64-cpython-310/sentencepiece/package_data
      copying src/sentencepiece/package_data/nmt_nfkc_cf.bin -> build/lib.linux-x86_64-cpython-310/sentencepiece/package_data
      running build_ext
      Package sentencepiece was not found in the pkg-config search path.
      Perhaps you should add the directory containing `sentencepiece.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'sentencepiece' found
      CMake Error: The source directory "/tmp/pip-install-rp8eg1yg/sentencepiece_8f8918fd16e140c0b8c3c18102c0a7bf/build" does not appear to contain CMakeLists.txt.
      Specify --help for usage, or press the help button on the CMake GUI.
      Unknown argument --parallel
      Unknown argument 224
      Usage: cmake --build <dir> [options] [-- [native-options]]
      Options:
        <dir>          = Project binary directory to be built.
        --target <tgt> = Build <tgt> instead of default targets.
                         May only be specified once.
        --config <cfg> = For multi-configuration tools, choose <cfg>.
        --clean-first  = Build target 'clean' first, then build.
                         (To clean only, use --target 'clean'.)
        --use-stderr   = Ignored.  Behavior is default in CMake >= 3.0.
        --             = Pass remaining options to the native tool.
      Traceback (most recent call last):
        File "/share/home/xxxx/miniconda3/envs/py3x/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/share/home/xxxx/miniconda3/envs/py3x/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
        File "/share/home/xxxx/miniconda3/envs/py3x/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
          return _build_backend().build_wheel(
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 435, in build_wheel
          return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)])
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 423, in _build
          return self._build_with_temp_dir(
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 404, in _build_with_temp_dir
          self.run_setup()
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
        File "<string>", line 235, in <module>
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 115, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 186, in setup
          return run_commands(dist)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1102, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/command/bdist_wheel.py", line 370, in run
          self.run_command("build")
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1102, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1102, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 96, in run
          _build_ext.run(self)
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 368, in run
          self.build_extensions()
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 484, in build_extensions
          self._build_extensions_serial()
        File "/tmp/pip-build-env-0doefphb/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 510, in _build_extensions_serial
          self.build_extension(ext)
        File "<string>", line 95, in build_extension
        File "/share/home/xxxx/miniconda3/envs/py3x/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['./build_bundled.sh', '0.2.1']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for sentencepiece
Successfully built xformers
Failed to build pyzmq sentencepiece
error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects
╰─> pyzmq, sentencepiece

这就是说编译环境缺失系统头文件/库导致的构建失败,于是我执行

pip install --force-reinstall --no-cache-dir pyzmq sentencepiece

按照了pyzmq和sentencepiece,但是只有后者安装成功了,前面的pyzmq还是没有成功,继续执行那条带'--pre'的指令之后继续报错:

Building wheels for collected packages: pyzmq
  Building wheel for pyzmq (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pyzmq (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [38 lines of output]
      *** scikit-build-core 0.11.6 using CMake 4.1.0 (wheel)
      *** Configuring CMake...
      loading initial cache file /tmp/tmpcj24cbn4/build/CMakeInit.txt
      -- The C compiler identification is GNU 11.2.0
      -- The CXX compiler identification is GNU 11.2.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /share/home/xxxx/miniconda3/envs/py3x/bin/gcc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /share/home/xxxx/miniconda3/envs/py3x/bin/g++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Building pyzmq for Linux 3.10.0-1160.el7.x86_64
      -- Found Python: /share/home/xxxx/miniconda3/envs/py3x/bin/python3.10 (found version "3.10.0") found components: Interpreter Development.Module
      -- Looking for libzmq
      -- Looking for libzmq - Found with cmake: /share/home/xxxx/miniconda3/envs/py3x/lib/libzmq.so
      -- Using Python Python /share/home/xxxx/miniconda3/envs/py3x/bin/python3.10
      -- Building Cython backend
      -- Linking libzmq target libzmq
      -- Configuring done (1.2s)
      -- Generating done (0.0s)
      -- Build files have been written to: /tmp/tmpcj24cbn4/build
      *** Building project with Ninja...
      [1/3] Generating _src/_zmq.c
      [2/3] Building C object CMakeFiles/_zmq.dir/_src/_zmq.c.o
      FAILED: [code=1] CMakeFiles/_zmq.dir/_src/_zmq.c.o
      /share/home/xxxx/miniconda3/envs/py3x/bin/gcc  -pthread -B /share/home/xxx/miniconda3/envs/py3x/compiler_compat -D_zmq_EXPORTS -I/tmp/pip-install-xhkn1lwc/pyzmq_e03d59211b884b1a99733aa0392fdb82/zmq/utils -isystem /share/home/xxxx/miniconda3/envs/py3x/include/python3.10 -isystem /share/home/xxxx/miniconda3/envs/py3x/include -O3 -DNDEBUG -fPIC -MD -MT CMakeFiles/_zmq.dir/_src/_zmq.c.o -MF CMakeFiles/_zmq.dir/_src/_zmq.c.o.d -o CMakeFiles/_zmq.dir/_src/_zmq.c.o -c /tmp/tmpcj24cbn4/build/_src/_zmq.c
      In file included from /tmp/tmpcj24cbn4/build/_src/_zmq.c:11:
      /share/home/xxxx/miniconda3/envs/py3x/include/python3.10/Python.h:44:10: fatal error: crypt.h: No such file or directory
         44 | #include <crypt.h>
            |          ^~~~~~~~~
      compilation terminated.
      ninja: build stopped: subcommand failed.
      
      *** CMake build failed
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyzmq
Failed to build pyzmq
error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects
╰─> pyzmq

于是大模型建议我换成“wheel”版的pyzmq,也就是先卸载原有的pyzmq,然后重新使用wheel版对pyzmq进行重新安装,彻底卸载的话是执行:

pip uninstall -y pyzmq
conda remove -y pyzmq

强制只拉binary wheel(禁止回退到源码)版的话是执行:

pip install --force-reinstall --upgrade --only-binary :all: pyzmq

验证代码:

python -c "
import zmq, distutils.util
print('pyzmq', zmq.pyzmq_version())
print('platform', distutils.util.get_platform())
"

得到了这样的结果:

说明安装的是wheel版的pyzmq。

最后再继续执行带'--pre'的那条指令(因为前面一直没有成功),最后就成功安装了vllm。

有一篇博客我是参考了一下,虽然按照他的方法没有成功安装,但是gcc的升级办法确实感觉有帮助到我:vllm安装踩坑记。在此对作者表达真挚的感谢!

http://www.dtcms.com/a/394028.html

相关文章:

  • 探索 Event 框架实战指南:微服务系统中的事件驱动通信:
  • FPGA超高速接口GTP_GTY_GTX使用说明
  • Blender常用第三方插件总结
  • Kurt-Blender零基础教程:第2章:建模篇——第3节:陈列/父子级/蒙皮/置换修改器与小狐狸角色建模
  • npm启动项目报错“无法加载文件……”
  • 从 0 到 1 精通 Nacos:服务发现与配置中心的实战指南
  • 基于DrissionPage的趣易百影院数据采集实战指南
  • github十大开源FPGA项目
  • R语言 csv新增一列 dplyr操作
  • IDEA创建Module子项目后,只有一个普通的文件夹
  • 支持向量机深度解析:从数学原理到工程实践的完整指南
  • 2025华为杯研究生数学建模竞赛B题及求解思路
  • 三星CIS全球产能布局解析:本土根基、海外扩张与策略雄心
  • js集装箱号校验算法
  • 【机器学习】最优传输(OT)和 KL散度的区别
  • 推荐一个随机生成图片的网站: Lorem Picsum
  • APE自动化提示词工程
  • 探究某黄鱼x-sign生成算法——终极篇
  • 霍尔传感器安装错位下的FOC控制:线性插值与锁相环(PLL)算法的抉择
  • FFmpeg 深入精讲(三)FFmpeg 中级开发
  • AI驱动下的蛋白质设计
  • ARM基本汇编操作指令
  • 电商搜索 API 的优化与性能提升:从瓶颈突破到体验升级
  • 使用DeepSeek辅助测试一个rust编写的postgresql协议工具包convergence
  • 【00】EPGF 架构搭建教程之 总揽篇
  • 深度剖析 vector 底层原理:从手写实现到核心技术点全解析
  • 嵌入式开发学习日志29——stm32之定时器中断
  • 通俗范畴论17.3 向量空间的对偶与双对偶
  • 表格 表头增加悬浮提示内容
  • emacs段落重排快捷键