一个apt的依赖关系问题 - 20.1111

在尝试使用apt安装软件时遇到了依赖关系错误,错误提示包括'E: Sub-process /usr/bin/dpkg returned an error code (1)'。尝试了多种百度上的解决方法无效。最终在Stack Overflow上找到答案,问题根源是config.dat文件被其他进程占用。通过运行'fuser -v /var/lib/dpkg/info/config.dat'找出占用进程,并使用'kill <PID>'杀死该进程,从而成功解决问题。
  • 错误信息

最近在用apt去安装东西的时候,总是会遇到下面这样的问题:

sudo apt install ./zoom_amd64.deb		#比方说我在安装zoom,下面是报的错误

正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
您也许需要运行“apt --fix-broken install”来修正上面的错误。
下列软件包有未满足的依赖关系:
 libatomic1 : 依赖: gcc-8-base (= 8.3.0-6ubuntu1~18.04.1) 但是 8.4.0-1ubuntu1~18.04 已经安装
 libc6-dbg : 依赖: libc6 (= 2.27-3ubuntu1.2) 但是 2.27-3ubuntu1 已经安装
 libc6-dev : 依赖: libc6 (= 2.27-3ubuntu1.2) 但是 2.27-3ubuntu1 已经安装
 libc6-i386 : 依赖: libc6 (= 2.27-3ubuntu1.2) 但是 2.27-3ubuntu1 已经安装
 libcc1-0 : 依赖: gcc-8-base (= 8.3.0-6ubuntu1~18.04.1) 但是 8.4.0-1ubuntu1~18.04 已经安装
 libgcc1:i386 : 依赖: libc6:i386 (>= 2.2.4) 但是它还没有被安装
 libgomp1 : 依赖: gcc-8-base (= 8.3.0-6ubuntu1~18.04.1) 但是 8.4.0-1ubuntu1~18.04 已经安装
 liblsan0 : 依赖: gcc-8-base (= 8.3.0-6ubuntu1~18.04.1) 但是 8.4.0-1ubuntu1~18.04 已经安装
 libmpx2 : 依赖: gcc-8-base (= 8.3.0-6ubuntu1~18.04.1) 但是 8.4.0-1ubuntu1~18.04 已经安装
 libobjc4 : 依赖: gcc-8-base (= 8.3.0-6ubuntu1~18.04.1) 但是 8.4.0-1ubuntu1~18.04 已经安装
 libstdc++6 : 依赖: gcc-8-base (= 8.3.0-6ubuntu1~18.04.1) 但是 8.4.0-1ubuntu1~18.04 已经安装
 libtsan0 : 依赖: gcc-8-base (= 8.3.0-6ubuntu1~18.04.1) 但是 8.4.0-1ubuntu1~18.04 已经安装
E: 有未能满足的依赖关系。请尝试不指明软件包的名字来运行“apt --fix-broken install”(也可以指定一个解决办法)。

最直接的提示是用 apt --fix-broken install,但运行这条命令依然会报错:

正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
正在修复依赖关系... 完成
将会同时安装下列软件:
  libatomic1 libc6 libc6:i386 libcc1-0 libgomp1 liblsan0 libmpx2 libobjc4 libstdc++6 libtsan0
建议安装:
  glibc-doc glibc-doc:i386 locales:i386
下列【新】软件包将被安装:
  libc6:i386
下列软件包将被升级:
  libatomic1 libc6 libcc1-0 libgomp1 liblsan0 libmpx2 libobjc4 libstdc++6 libtsan0
升级了 9 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 358 个软件包未被升级。
有 10 个软件包没有被完全安装或卸载。
需要下载 0 B/6,387 kB 的归档。
解压缩后会消耗 10.8 MB 的额外空间。
您希望继续执行吗? [Y/n] y
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: 警告: 无法找到软件包 libssl1.1:amd64 的文件名列表文件,现假定该软件包目前没有任何文件被安装在系统里。
(正在读取数据库 ... 系统当前共安装有 164234 个文件和目录。)
正准备解包 .../libc6_2.27-3ubuntu1.2_amd64.deb  ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: 处理归档 /var/cache/apt/archives/libc6_2.27-3ubuntu1.2_amd64.deb (--unpack)时出错:
 new libc6:amd64 package pre-installation script subprocess returned error exit status 1
正准备解包 .../libc6_2.27-3ubuntu1.2_i386.deb  ...
正在反配置 libc6:amd64 (2.27-3ubuntu1) ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: 处理归档 /var/cache/apt/archives/libc6_2.27-3ubuntu1.2_i386.deb (--unpack)时出错:
 new libc6:i386 package pre-installation script subprocess returned error exit status 1
在处理时有错误发生:
 /var/cache/apt/archives/libc6_2.27-3ubuntu1.2_amd64.deb
 /var/cache/apt/archives/libc6_2.27-3ubuntu1.2_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试了百度上诸多的关于“E: Sub-process /usr/bin/dpkg returned an error code (1)”的错误解决方案,但都不能解决这个问题。

  • 解决办法

最后在stackoverflow上找到了解答:
stackoverflow
https://stackoverflow.com/questions/62843154/i-cant-run-apt-get-commands-apt-fix-broken-install-doesnt-work-the-followi

在第二个错误信息里,有这么一段:

debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable

config.dat被另一个进程锁定,资源暂时不可用。如果你用fuser -v去看这个config.dat

sudo fuser -v  /var/cache/debconf/config.dat

                     用户     进程号 权限   命令
/var/cache/debconf/config.dat:
                     root       6202 F.... frontend

就可以看到是6202这个进程在占用config.dat,下面你只需要

sudo kill <PID>		#这里PID=6202

这样就可以正常的

sudo apt-get install -f 
sudo apt-get update
[21:10:36.576] Log Level: 2 [21:10:36.609] SSH Resolver called for "ssh-remote+222.20.94.68", attempt 1 [21:10:36.615] remote.SSH.useLocalServer = false [21:10:36.616] remote.SSH.useExecServer = true [21:10:36.616] remote.SSH.bindHost = {} [21:10:36.616] remote.SSH.showLoginTerminal = false [21:10:36.617] remote.SSH.remotePlatform = {} [21:10:36.617] remote.SSH.path = [21:10:36.617] remote.SSH.configFile = [21:10:36.618] remote.SSH.useFlock = true [21:10:36.618] remote.SSH.lockfilesInTmp = false [21:10:36.618] remote.SSH.localServerDownload = auto [21:10:36.619] remote.SSH.remoteServerListenOnSocket = false [21:10:36.619] remote.SSH.defaultExtensions = [] [21:10:36.619] remote.SSH.defaultExtensionsIfInstalledLocally = [] [21:10:36.620] remote.SSH.loglevel = 2 [21:10:36.620] remote.SSH.enableDynamicForwarding = true [21:10:36.620] remote.SSH.enableRemoteCommand = false [21:10:36.621] remote.SSH.serverPickPortsFromRange = {} [21:10:36.621] remote.SSH.serverInstallPath = "~/.vscode-server-legacy" [21:10:36.621] remote.SSH.permitPtyAllocation = false [21:10:36.621] remote.SSH.preferredLocalPortRange = undefined [21:10:36.622] remote.SSH.useCurlAndWgetConfigurationFiles = false [21:10:36.622] remote.SSH.experimental.chat = true [21:10:36.622] remote.SSH.experimental.enhancedSessionLogs = true [21:10:36.623] remote.SSH.httpProxy = {"*":""} [21:10:36.623] remote.SSH.httpsProxy = {"*":""} [21:10:36.640] VS Code version: 1.106.2 [21:10:36.640] Remote-SSH version: remote-ssh@0.120.0 [21:10:36.640] win32 x64 [21:10:36.647] SSH Resolver called for host: 222.20.94.68 [21:10:36.647] Setting up SSH remote "222.20.94.68" [21:10:36.662] Using commit id "1e3c50d64110be466c0b4a45222e81d2c9352888" and quality "stable" for server [21:10:36.662] Extensions to install: [21:10:36.672] Install and start server if needed [21:11:39.621] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V" [21:11:39.626] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT [21:11:39.626] Checking ssh with "C:\WINDOWS\ssh.exe -V" [21:11:39.628] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT [21:11:39.629] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V" [21:11:39.631] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT [21:11:39.631] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V" [21:11:39.633] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT [21:11:39.633] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V" [21:11:39.714] > OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2 [21:11:39.723] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 60135 "222.20.94.68" sh [21:11:39.726] Generated SSH command: &#39;type "C:\Users\LENOVO\AppData\Local\Temp\vscode-linux-multi-line-command-222.20.94.68-197378319.sh" | "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 60135 "222.20.94.68" sh&#39; [21:11:39.728] Using connect timeout of 17 seconds [21:11:39.729] Terminal shell path: C:\WINDOWS\System32\cmd.exe [21:11:40.061] > [21:11:40.062] Got some output, clearing connection timeout [21:11:40.075] > [21:11:40.108] > [21:11:40.139] > Active code page: 65001 > > > > > > > > > > > > > > > > > > > > > > > > > > > > [21:11:40.293] > Enter passphrase for key &#39;C:\Users\LENOVO/.ssh/id_ed25519&#39;: [21:11:40.294] Detected passphrase message [21:11:44.575] Got passphrase response [21:11:44.576] "install" wrote data to terminal: "***" [21:11:44.604] > [21:11:46.422] > 55bc51c4a242: running > Script executing under PID: 17701 [21:11:46.456] > Found existing installation at /home/qinggangw/.vscode-server... > Starting VS Code CLI... > Removing old logfile at /home/qinggangw/.vscode-server/.cli.1e3c50d64110be466c0b4a45222e81d2c9352888.log [21:11:46.469] > Spawned remote CLI: 17719 > Waiting for server log... [21:11:46.501] > Waiting for server log... [21:11:46.530] > Waiting for server log... [21:11:46.562] > sh: 418: kill: No such process [21:11:46.579] > Exec server process not found > [2025-11-25 13:11:46] error This machine does not meet Visual Studio Code Server&#39;s prerequisites, expected either... > - find GLIBC >= v2.28.0 (but found v2.27.0 instead) for GNU environments > - find /lib/ld-musl-x86_64.so.1, which is required to run the Visual Studio Code Server in musl environments > 55bc51c4a242: start > exitCode==207== > listeningOn==== > osReleaseId==ubuntu== > arch==x86_64== > vscodeArch==x64== > bitness==64== > tmpDir==/run/user/1023== > platform==linux== > unpackResult==== > didLocalDownload==0== > downloadTime==== > installTime==== > serverStartTime==== > execServerToken==1aaa11a1-1111-1a11-1111-a111111111aa== > platformDownloadPath==cli-alpine-x64== > SSH_AUTH_SOCK==== > DISPLAY==== > 55bc51c4a242: end [21:11:46.579] Received install output: exitCode==207== listeningOn==== osReleaseId==ubuntu== arch==x86_64== vscodeArch==x64== bitness==64== tmpDir==/run/user/1023== platform==linux== unpackResult==== didLocalDownload==0== downloadTime==== installTime==== serverStartTime==== execServerToken==1aaa11a1-1111-1a11-1111-a111111111aa== platformDownloadPath==cli-alpine-x64== SSH_AUTH_SOCK==== DISPLAY==== [21:11:46.581] Resolver error: Error: 远程主机不满足运行VS Code服务器的先决条件 at y.ServerInstallError (c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:744694) at p (c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:739113) at t.handleInstallOutput (c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:740589) at t.tryInstall (c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:865534) at async c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:824246 at async t.withShowDetailsEvent (c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:827501) at async A (c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:820760) at async t.resolve (c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:824898) at async c:\Users\LENOVO\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:1113660 [21:11:46.590] ------ [21:11:46.590] ---------- [Session Summary] ----------- [21:11:46.591] [LinuxPrereqs]: 远程主机可能不符合 glibc 和 libstdc++ VS Code 服务器的先决条件 (远程主机不满足运行VS Code服务器的先决条件) [21:11:46.591] ---------------------------------------- [21:11:47.201] > [21:11:47.859] "install" terminal command done [21:11:47.859] User entered passphrase [21:11:47.863] Passphrase was entered and ssh config entry was found - adding SSH key to agent [21:11:47.865] Executing add-ssh-key: powershell -ExecutionPolicy Bypass C:\Users\LENOVO\AppData\Local\Temp\vscode_add_ssh_key_to_agent.ps1 [21:11:47.866] Terminal shell path: C:\WINDOWS\System32\cmd.exe [21:11:47.866] "add-ssh-key" wrote data to terminal: "powershell -ExecutionPolicy Bypass C:\Users\LENOVO\AppData\Local\Temp\vscode_add_ssh_key_to_agent.ps1" [21:11:48.344] > [21:11:48.373] > [21:11:48.389] > Microsoft Windows [版本 10.0.26100.7171] > (c) Microsoft Corporation。保留所有权利。 [21:11:48.404] > [21:11:48.422] > Active code page: 65001 > > C:\Users\LENOVO>(powershell -ExecutionPolicy Bypass C:\Users\LENOVO\AppData\Local\Temp\vscode_add_ssh_key_to_agent.ps1) & exit /b 0 > > > > > > > > > > > > > > > > > > > > > > > > > [21:11:48.437] > [21:11:48.926] > PS: adding key to ssh-agent [21:11:48.927] > > ssh-add [21:11:48.953] > Error connecting to agent: No such file or directory [21:11:48.968] > 9523dd999167##5## [21:11:48.968] ssh-add failed [21:11:48.969] Consider setting up the ssh agent: https://aka.ms/vscode-remote/troubleshooting#_setting-up-the-ssh-agent [21:11:48.982] > [21:11:48.982] ssh-add failed [21:11:48.982] Consider setting up the ssh agent: https://aka.ms/vscode-remote/troubleshooting#_setting-up-the-ssh-agent [21:11:50.271] "add-ssh-key" terminal command done [21:11:50.271] Install terminal quit with output:
11-26
上下文啊,c盘问题前是到了这一步,我希望围绕这一步和C盘问题给我完整步骤:你的命令有一些需要自定义内容的部分,我不会,目前我wsl命令是在hero@DESKTOP-0H3JHPB:~/stable-diffusion-docker$下进行的,hero是我的用户名称,seeepseek教我设置的,root权限,请你能根据这些信息为我完善步骤 回答 我们已经在之前的步骤中创建了持久化目录,现在用户希望以root权限在特定目录下完善命令。 用户当前目录:/home/hero/stable-diffusion-docker(注意:用户提示的目录是hero@DESKTOP-0H3JHPB:~/stable-diffusion-docker$,所以绝对路径是/home/hero/stable-diffusion-docker) 用户要求:以root权限完善包含自定义内容部分的命令操作步骤。 之前给出的Docker命令已经考虑了持久化,但需要将命令中的“你的用户名”替换为实际的用户名(这里是hero)。 同时,我们注意到用户可能已经创建了目录,所以这里我们直接使用这些目录。 我们将提供两个版本的命令: 首次运行的完整命令(包括安装依赖和克隆仓库) 后续运行的简化命令(直接启动WebUI) 注意:由于用户要求以root权限操作,但Docker命令本身不需要在WSL内部使用root(除非有权限问题),通常使用普通用户运行docker即可。但如果用户坚持要以root运行,那么请注意目录权限。 然而,在WSL中,我们通常使用普通用户。这里我们假设用户希望以普通用户身份运行(因为用户当前提示符是hero@DESKTOP...)。 如果用户确实需要以root权限运行Docker容器,那么命令前面可能需要加sudo,但Docker默认需要sudo或者将用户加入docker组。我们假设用户已经将用户加入docker组(通常安装Docker时会提示),所以不需要sudo。 因此,我们提供以下步骤: 步骤1:确保目录存在(如果之前没创建,可以创建) 步骤2:使用修改后的Docker命令(替换用户名为hero,并确保路径正确) 但是,注意:在WSL中,路径是Linux路径,所以命令中的路径应该是: -v /home/hero/stable-diffusion/models:/models … 以此类推 另外,用户当前在~/stable-diffusion-docker目录(即/home/hero/stable-diffusion-docker),但我们的持久化目录是~/stable-diffusion(即/home/hero/stable-diffusion)。这并不冲突,因为用户可能在任意目录执行命令。 我们按照用户要求,提供完善后的命令(自定义部分用实际值替换): 首次运行命令(在WSL终端中执行): Bash docker run -it --rm --name sd-webui \ --device=/dev/dri/card0 \ --device=/dev/dri/renderD128 \ --device=/dev/kfd \ --group-add=video \ -p 127.0.0.1:7860:7860 \ -v /home/hero/stable-diffusion/models:/models \ -v /home/hero/stable-diffusion/outputs:/outputs \ -v /home/hero/stable-diffusion/code:/code \ rocm/pytorch:latest \ bash -c "apt update && \ apt install -y python3-dev python3-venv libgl1 libglib2.0-0 && \ cd /code && \ git clone https://gitee.com/mirrors/stable-diffusion-webui.git && \ cd stable-diffusion-webui && \ python3 -m venv venv && \ source venv/bin/activate && \ pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \ pip install --upgrade pip && \ python3 launch.py --port 7860 --skip-torch-cuda-test" 注意:这个命令会执行较长时间,因为需要安装系统包、克隆仓库、创建虚拟环境、安装Python依赖,最后启动WebUI。 后续启动命令(在首次运行成功后,以后每次启动只需要激活虚拟环境并运行): Bash docker run -it --rm --name sd-webui \ --device=/dev/dri/card0 \ --device=/dev/dri/renderD128 \ --device=/dev/kfd \ --group-add=video \ -p 127.0.0.1:7860:7860 \ -v /home/hero/stable-diffusion/models:/models \ -v /home/hero/stable-diffusion/outputs:/outputs \ -v /home/hero/stable-diffusion/code:/code \ rocm/pytorch:latest \ bash -c "cd /code/stable-diffusion-webui && source venv/bin/activate && python3 launch.py --port 7860 --ckpt-dir /models" 步骤说明: 首次运行:会安装必要的系统包,创建虚拟环境,安装Python依赖,然后启动WebUI。 后续运行:直接进入项目目录,激活虚拟环境,然后启动WebUI。 注意:如果用户需要以root权限执行Docker命令,可以在命令前加sudo,但通常不需要(因为用户hero应该在docker组中)。如果出现权限问题,可以尝试加sudo或者检查docker组权限。 另外,关于自定义模型: 用户只需将下载的模型文件(如model.ckpt)放入/home/hero/stable-diffusion/models目录,在WebUI中就可以选择使用。 重要提示:首次启动WebUI时,它会自动下载一些必要的模型(如VAE等),这些也会放在/models目录下(因为我们在启动命令中指定了--ckpt-dir /models,但第一次启动时我们并没有加这个参数。实际上,在首次启动时,我们使用的是默认参数,而后续启动我们指定了ckpt目录。不过,Stable Diffusion WebUI默认会从项目目录下的models/Stable-diffusion目录读取模型,而我们的挂载点/models在容器内对应的是/models,所以在首次启动后,我们可以通过修改WebUI的设置来改变模型路径,或者按照上述后续命令直接指定--ckpt-dir。 但为了统一,我们可以在首次启动命令中也加上--ckpt-dir /models,这样从第一次开始就会使用这个目录。因此,我们可以调整首次启动命令的末尾为: … && python3 launch.py --port 7860 --skip-torch-cuda-test --ckpt-dir /models" 这样,首次启动就会使用我们挂载的模型目录。 因此,修改后的首次运行命令: Bash docker run -it --rm --name sd-webui \ --device=/dev/dri/card0 \ --device=/dev/dri/renderD128 \ --device=/dev/kfd \ --group-add=video \ -p 127.0.0.1:7860:7860 \ -v /home/hero/stable-diffusion/models:/models \ -v /home/hero/stable-diffusion/outputs:/outputs \ -v /home/hero/stable-diffusion/code:/code \ rocm/pytorch:latest \ bash -c "apt update && \ apt install -y python3-dev python3-venv libgl1 libglib2.0-0 && \ cd /code && \ git clone https://gitee.com/mirrors/stable-diffusion-webui.git && \ cd stable-diffusion-webui && \ python3 -m venv venv && \ source venv/bin/activate && \ pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \ pip install --upgrade pip && \ python3 launch.py --port 7860 --skip-torch-cuda-test --ckpt-dir /models" 后续命令不变(已经指定了ckpt目录)。 如果用户已经下载了模型,请将模型放在/home/hero/stable-diffusion/models目录下,然后在WebUI的左上角模型选择处可以看到。 最后,关于权限:由于我们在容器内是以root用户运行的(因为rocm/pytorch镜像默认用户是root),所以生成的文件在容器内是root权限。但是,我们通过挂载卷,在宿主机(WSL)上,这些文件属于宿主机的用户(hero)吗?这取决于WSL的权限设置。通常,WSL的文件权限和宿主机是独立的,所以容器内root创建的文件在WSL中也会是root权限。为了解决这个问题,我们可以在容器内使用与宿主机相同的UID和GID来运行命令。 但是,为了简化,我们可以在首次运行后,在宿主机上修改这些文件的权限(如果出现权限问题): sudo chown -R hero:hero /home/hero/stable-diffusion 或者,我们可以调整Docker命令,使用宿主机的UID和GID在容器内创建用户并切换,但这比较复杂。如果用户遇到权限问题,再单独处理。 现在,我们提供最终的命令,并假设用户没有权限问题(因为WSL通常没有严格的权限控制)。 执行步骤: 打开WSL终端,确保当前目录无特别要求(可以在任意目录执行) 复制并执行首次运行命令(等待完成,时间较长) 完成后,在Windows浏览器中访问:http://localhost:7860 如果中途断开网络导致中断,可以重新执行相同的命令(因为代码已经克隆到/code目录,所以git会提示已存在,但其他步骤会继续执行,pip安装会跳过已安装的包)。如果遇到错误,可能需要删除/code/stable-diffusion-webui目录(在WSL中执行rm -rf /home/hero/stable-diffusion/code/stable-diffusion-webui)再重新执行命令。 注意:模型文件较大,确保磁盘空间足够(建议至少20GB可用空间)。 相关问题: 如何解决Docker容器中生成的文件在宿主机上权限问题? 如何自定义Stable Diffusion WebUI的插件和扩展? 如何更新Stable Diffusion WebUI到最新版本? 如何配置Stable Diffusion WebUI使用多个模型目录? 好的,我将以小白能理解的方式,一步步指导您在 WSL 环境下以 root 权限完成 Stable Diffusion WebUI 的安装和配置。请按照以下步骤操作: 完整操作步骤(在 WSL 终端执行) 进入工作目录(使用您的用户名 hero) Bash cd /home/hero/stable-diffusion-docker 创建持久化存储目录(模型/输出/代码分开存放) Bash sudo mkdir -p ./data/{models,outputs,code} sudo chown -R $USER:$USER ./data # 确保您有操作权限 创建并运行 Docker 容器(完整命令) Bash sudo docker run -itd --name sd-webui \ --restart unless-stopped \ --device=/dev/dri/card0 \ --device=/dev/dri/renderD128 \ --device=/dev/kfd \ --group-add=video \ -p 127.0.0.1:7860:7860 \ -v $PWD/data/models:/models \ -v $PWD/data/outputs:/outputs \ -v $PWD/data/code:/code \ rocm/pytorch:latest \ bash -c "apt update && \ apt install -y python3-dev python3-venv libgl1 libglib2.0-0 git && \ cd /code && \ git clone https://gitee.com/mirrors/stable-diffusion-webui.git && \ cd stable-diffusion-webui && \ python3 -m venv venv && \ source venv/bin/activate && \ pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \ pip install --upgrade pip wheel && \ python3 launch.py --port 7860 --skip-torch-cuda-test --ckpt-dir /models" 关键参数说明(自定义部分) --name sd-webui:给容器命名,便于管理 -v $PWD/data/models:/models:模型存储位置(自定义模型放这里) Windows 访问路径:\\wsl.localhost\Ubuntu\home\hero\stable-diffusion-docker\data\models -v $PWD/data/outputs:/outputs:生成图片保存位置 git clone 使用国内镜像加速下载 pip config 设置清华源加速安装 --ckpt-dir /models 指定模型加载目录 操作后检查 Bash # 查看容器运行状态 sudo docker ps # 查看实时日志(看到 "Running on local URL" 表示成功) sudo docker logs -f sd-webui 模型安装步骤 下载模型文件(如 v1-5-pruned-emaonly.ckpt) 放入模型目录: Bash # 示例:将下载的模型移动到正确位置 mv ~/Downloads/v1-5-pruned-emaonly.ckpt /home/hero/stable-diffusion-docker/data/models/ 在 WebUI 界面左上角选择模型 后续管理命令 操作 命令 启动容器 sudo docker start sd-webui 停止容器 sudo docker stop sd-webui 进入容器 sudo docker exec -it sd-webui bash 删除容器 sudo docker rm -f sd-webui(不会删除模型数据) 访问方式 浏览器打开:http://localhost:7860 注意:首次运行会自动下载约 10GB 基础模型,请保持网络稳定。中断后可重新运行命令继续下载1
最新发布
11-27
(process:6648): VIPS-WARNING **: 00:42:28.228: unable to load "C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-heif.dll" -- &#39;C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-heif.dll&#39;: 找不到指定的模块。 (process:6648): VIPS-WARNING **: 00:42:28.231: unable to load "C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-jxl.dll" -- &#39;C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-jxl.dll&#39;: 找不到指定的模块。 (process:6648): VIPS-WARNING **: 00:42:28.231: unable to load "C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-magick.dll" -- &#39;C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-magick.dll&#39;: 找不到指定的模块。 (process:6648): VIPS-WARNING **: 00:42:28.231: unable to load "C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-openslide.dll" -- &#39;C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-openslide.dll&#39;: 找不到指定的模块。 (process:6648): VIPS-WARNING **: 00:42:28.231: unable to load "C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-poppler.dll" -- &#39;C:\Ruby34-x64\msys64\ucrt64/lib/vips-modules-8.17\vips-poppler.dll&#39;: 找不到指定的模块。 bin/rails aborted! Bundler::GemRequireError: There was an error while trying to load the gem &#39;sqlite3&#39;. (Bundler::GemRequireError) Gem Load Error is: cannot load such file -- sqlite3/sqlite3_native Backtrace for gem load error is: C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in &#39;Kernel.require&#39; C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in &#39;block (2 levels) in Kernel#replace_require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/bootsnap-1.18.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in &#39;Kernel#require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/zeitwerk-2.7.3/lib/zeitwerk/core_ext/kernel.rb:34:in &#39;Kernel#require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/sqlite3-2.8.0-x64-mingw-ucrt/lib/sqlite3.rb:6:in &#39;<main>&#39; <internal:C:/Ruby34-x64/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:37:in &#39;Kernel#require&#39; <internal:C:/Ruby34-x64/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:37:in &#39;Kernel#require&#39; C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in &#39;block (2 levels) in Kernel.replace_require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/zeitwerk-2.7.3/lib/zeitwerk/core_ext/kernel.rb:34:in &#39;Kernel.require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/lib/bundler/runtime.rb:63:in &#39;block (2 levels) in Bundler::Runtime#require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/lib/bundler/runtime.rb:58:in &#39;Array#each&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/lib/bundler/runtime.rb:58:in &#39;block in Bundler::Runtime#require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/lib/bundler/runtime.rb:52:in &#39;Array#each&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/lib/bundler/runtime.rb:52:in &#39;Bundler::Runtime#require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/bundler-2.7.2/lib/bundler.rb:214:in &#39;Bundler.require&#39; D:/1111/blog/config/application.rb:7:in &#39;<main>&#39; D:/1111/blog/Rakefile:4:in &#39;Kernel#require_relative&#39; D:/1111/blog/Rakefile:4:in &#39;<main>&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/rake-13.3.1/lib/rake/rake_module.rb:29:in &#39;Kernel#load&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/rake-13.3.1/lib/rake/rake_module.rb:29:in &#39;Rake.load_rakefile&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/rake-13.3.1/lib/rake/application.rb:740:in &#39;Rake::Application#raw_load_rakefile&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/rake-13.3.1/lib/rake/application.rb:126:in &#39;block in Rake::Application#load_rakefile&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/rake-13.3.1/lib/rake/application.rb:214:in &#39;Rake::Application#standard_exception_handling&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/rake-13.3.1/lib/rake/application.rb:125:in &#39;Rake::Application#load_rakefile&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/railties-8.1.1/lib/rails/commands/rake/rake_command.rb:43:in &#39;block in Rails::Command::RakeCommand.with_rake&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/rake-13.3.1/lib/rake/rake_module.rb:59:in &#39;Rake.with_application&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/railties-8.1.1/lib/rails/commands/rake/rake_command.rb:41:in &#39;Rails::Command::RakeCommand.with_rake&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/railties-8.1.1/lib/rails/commands/rake/rake_command.rb:20:in &#39;Rails::Command::RakeCommand.perform&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/railties-8.1.1/lib/rails/command.rb:150:in &#39;Rails::Command.invoke_rake&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/railties-8.1.1/lib/rails/command.rb:67:in &#39;block in Rails::Command.invoke&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/railties-8.1.1/lib/rails/command.rb:143:in &#39;Rails::Command.with_argv&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/railties-8.1.1/lib/rails/command.rb:63:in &#39;Rails::Command.invoke&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/railties-8.1.1/lib/rails/commands.rb:18:in &#39;<main>&#39; C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in &#39;Kernel.require&#39; C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in &#39;block (2 levels) in Kernel#replace_require&#39; C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/bootsnap-1.18.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in &#39;Kernel#require&#39; bin/rails:4:in &#39;<main>&#39; Bundler Error Backtrace: D:/1111/blog/config/application.rb:7:in &#39;<main>&#39; D:/1111/blog/Rakefile:4:in &#39;Kernel#require_relative&#39; D:/1111/blog/Rakefile:4:in &#39;<main>&#39; bin/rails:4:in &#39;<main>&#39; Caused by: LoadError: cannot load such file -- sqlite3/sqlite3_native (LoadError) <internal:C:/Ruby34-x64/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:37:in &#39;Kernel#require&#39; <internal:C:/Ruby34-x64/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:37:in &#39;Kernel#require&#39; D:/1111/blog/config/application.rb:7:in &#39;<main>&#39; D:/1111/blog/Rakefile:4:in &#39;Kernel#require_relative&#39; D:/1111/blog/Rakefile:4:in &#39;<main>&#39; bin/rails:4:in &#39;<main>&#39; Caused by: LoadError: 127: 找不到指定的程序。 - C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/sqlite3-2.8.0-x64-mingw-ucrt/lib/sqlite3/3.4/sqlite3_native.so (LoadError) <internal:C:/Ruby34-x64/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:37:in &#39;Kernel#require&#39; <internal:C:/Ruby34-x64/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:37:in &#39;Kernel#require&#39; D:/1111/blog/config/application.rb:7:in &#39;<main>&#39; D:/1111/blog/Rakefile:4:in &#39;Kernel#require_relative&#39; D:/1111/blog/Rakefile:4:in &#39;<main>&#39; bin/rails:4:in &#39;<main>&#39; (See full trace by running task with --trace)
11-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值