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

Fedora 39运行Stable Diffusion WebUI遇Python版本不兼容问题求助

问题

在Fedora 39系统上运行Stable Diffusion WebUI时出现Python版本不兼容、无法安装torch的问题,此前在Fedora 38上运行正常。

系统信息

Kernel: 6.5.6-300.fc39.x86_64 arch: x86_64 bits: 64
    Console: pty pts/1 Distro: Fedora release 39 (Thirty Nine)
Machine:
  Type: Laptop System: LENOVO product: 82N6 v: Legion 7 16ACHg6
    serial: 
  Mobo: LENOVO model: LNVNB161216 v: NO DPK serial:  UEFI: LENOVO
    v: GKCN60WW date: 03/07/2023
Battery:
  ID-1: BAT0 charge: 47.4 Wh (60.0%) condition: 79.0/80.0 Wh (98.7%)
CPU:
  Info: 8-core model: AMD Ryzen 7 5800H with Radeon Graphics bits: 64
    type: MT MCP cache: L2: 4 MiB
  Speed (MHz): avg: 814 min/max: 400/3201 cores: 1: 512 2: 400 3: 400 4: 400
    5: 456 6: 2196 7: 400 8: 2518 9: 400 10: 400 11: 400 12: 456 13: 512 14: 400
    15: 400 16: 2781
Graphics:
  Device-1: NVIDIA GA104M [GeForce RTX 3080 Mobile / Max-Q 8GB/16GB]
    driver: nvidia v: 535.113.01
  Device-2: AMD Cezanne [Radeon Vega Series / Radeon Mobile Series]
    driver: amdgpu v: kernel
  Device-3: Bison Integrated Camera driver: uvcvideo type: USB
  Display: server: X.Org v: 23.2.1 with: Xwayland v: 23.2.1 driver: X:
    loaded: amdgpu,nvidia unloaded: fbdev,modesetting,nouveau,vesa dri: radeonsi
    gpu: amdgpu resolution: 1920x1200~60Hz
  API: OpenGL v: 4.6 Mesa 23.2.1 renderer: AMD Radeon Graphics (renoir LLVM
    16.0.6 DRM 3.54 6.5.6-300.fc39.x86_64)

错误信息

/webui.sh
 
################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################
 
################################################################
Running on semela user
################################################################
 
################################################################
Create and activate python venv
################################################################
 
################################################################
Launching launch.py...
################################################################
Using TCMalloc: libtcmalloc_minimal.so.4
=============================================================================================
INCOMPATIBLE PYTHON VERSION
 
This program is tested with 3.10.6 Python, but you have 3.12.0.
If you encounter an error with "RuntimeError: Couldn't install torch." message,
or any other error regarding unsuccessful package (library) installation,
please downgrade (or upgrade) to the latest version of 3.10 Python
and delete current Python and "venv" folder in WebUI's directory.
 
You can download 3.10 Python from here: https://www.python.org/downloads/release/python-3106/
 
 
 
Use --skip-python-version-check to suppress this warning.
=============================================================================================
Python 3.12.0 (main, Oct  2 2023, 00:00:00) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)]
Version: v1.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu118
ERROR: Could not find a version that satisfies the requirement torch==2.0.1 (from versions: none)
ERROR: No matching distribution found for torch==2.0.1
 
[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
Traceback (most recent call last):
  File "/home/semela/stable_diffusion/stable-diffusion-webui/launch.py", line 48, in <module>
    main()
  File "/home/semela/stable_diffusion/stable-diffusion-webui/launch.py", line 39, in main
    prepare_environment()
  File "/home/semela/stable_diffusion/stable-diffusion-webui/modules/launch_utils.py", line 352, in prepare_environment
    run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
  File "/home/semela/stable_diffusion/stable-diffusion-webui/modules/launch_utils.py", line 115, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "/home/semela/stable_diffusion/stable-diffusion-webui/venv/bin/python3" -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
Error code: 1

已尝试操作

  • 安装了Python3.10;
  • 修改webui-user.sh文件,将注释行的python_cmd从"python"改为"python3.10";
  • 删除venv文件夹后重新运行webui.sh,但问题仍未解决。

解决方案

你遗漏的关键步骤如下:

  1. 确保webui-user.sh的修改生效
    打开webui-user.sh,确认python_cmd="python3.10"这一行没有被注释(行首无#),保存文件后再执行启动脚本。

  2. 验证Python3.10的可用性
    在终端执行python3.10 --version,确认输出为Python 3.10.x版本。若提示命令不存在,需重新安装:

    sudo dnf install python3.10 python3.10-devel python3.10-pip
    
  3. 手动用Python3.10创建虚拟环境
    跳过脚本自动创建流程,手动构建适配的虚拟环境:

    # 删除旧虚拟环境
    rm -rf venv
    # 用Python3.10创建新虚拟环境
    python3.10 -m venv venv
    # 激活虚拟环境
    source venv/bin/activate
    # 升级pip到最新版
    pip install --upgrade pip
    # 安装指定版本的torch和torchvision
    pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
    # 启动WebUI
    ./webui.sh
    
  4. 适配CUDA版本调整torch安装命令
    你的NVIDIA驱动版本535.113.01支持CUDA 12.2,可尝试安装适配CUDA 12.1的torch版本:
    打开webui-user.sh,添加或修改:

    export TORCH_COMMAND="pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url https://download.pytorch.org/whl/cu121"
    

    保存后重新运行webui.sh。

  5. 清理pip缓存避免冲突
    执行以下命令清理pip缓存,消除旧版本包的干扰:

    pip cache purge
    

    之后重新运行webui.sh。


内容的提问来源于stack exchange,提问作者Alexander de Lioncourt

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 00:24:58