Stable diffusion加载safetensors 模型出现Exception: device privateuseone:0 is invalid

博主在尝试使用CPU运行StableDiffusion的最新模型时遇到错误,特别是切换到v1-5-pruned-emaonly.safetensors格式后,出现Exception:deviceprivateuseone:0isinvalid的问题。问题出在启动参数--lowram,它可能导致设备设置为GPU,而博主的电脑是AMD集成显卡。移除该参数并使用--use-cpuall成功解决了问题。
摘要由CSDN通过智能技术生成

一、问题

      博主用CPU硬解 Stable diffusion,sd-v1-4.ckpt能跑,但换成v1-5-pruned-emaonly.safetensors等最新格式的模型就出现Exception: device privateuseone:0 is invalid错误。

(automatic) C:\Users\tangtang1600>python "F:\ai\stable_diffusion\stable-diffusion-webui-directml\webui.py" --precision full --no-half  --lowram --use-cpu all 
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
No module 'xformers'. Proceeding without it.
Error setting up CodeFormer:
Traceback (most recent call last):
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\modules\codeformer_model.py", line 38, in setup_model
    from facelib.utils.face_restoration_helper import FaceRestoreHelper
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\repositories\CodeFormer\facelib\utils\face_restoration_helper.py", line 7, in <module>
    from facelib.detection import init_detection_model
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\repositories\CodeFormer\facelib\detection\__init__.py", line 10, in <module>
    from .retinaface.retinaface import RetinaFace
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\repositories\CodeFormer\facelib\detection\retinaface\retinaface.py", line 14, in <module>
    from basicsr.utils.misc import get_device
ImportError: cannot import name 'get_device' from 'basicsr.utils.misc' (D:\Users\tangtang1600\Anaconda3\envs\lib\site-packages\basicsr\utils\misc.py)

Error loading script: bilingual_localization_helper.py
Traceback (most recent call last):
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\modules\scripts.py", line 248, in load_scripts
    script_module = script_loading.load_module(scriptfile.path)
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\modules\script_loading.py", line 11, in load_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\extensions\sd-webui-bilingual-localization\scripts\bilingual_localization_helper.py", line 13, in <module>
    I18N_DIRS = { k: str(Path(v).relative_to(ROOT_DIR).as_posix()) for k, v in localization.localizations.items() }
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\extensions\sd-webui-bilingual-localization\scripts\bilingual_localization_helper.py", line 13, in <dictcomp>
    I18N_DIRS = { k: str(Path(v).relative_to(ROOT_DIR).as_posix()) for k, v in localization.localizations.items() }
  File "D:\Users\tangtang1600\Anaconda3\envs\automatic\lib\pathlib.py", line 818, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: 'F:\\ai\\stable_diffusion\\stable-diffusion-webui-directml\\extensions\\sd-webui-bilingual-localization\\localizations\\zh_CN.json' is not in the subpath of 'C:\\Users\\tangtang1600' OR one path is relative and the other is absolute.

Checkpoint sd-v1-4.ckpt [fe4efff1e1] not found; loading fallback other\chilloutmix_NiPrunedFp16Fix.safetensors [f78ded1eda]
Loading weights [f78ded1eda] from F:\ai\stable_diffusion\stable-diffusion-webui-directml\models\Stable-diffusion\other\chilloutmix_NiPrunedFp16Fix.safetensors
loading stable diffusion model: Exception
Traceback (most recent call last):
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\webui.py", line 135, in initialize
    modules.sd_models.load_model()
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\modules\sd_models.py", line 383, in load_model
    state_dict = get_checkpoint_state_dict(checkpoint_info, timer)
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\modules\sd_models.py", line 238, in get_checkpoint_state_dict
    res = read_state_dict(checkpoint_info.filename)
  File "F:\ai\stable_diffusion\stable-diffusion-webui-directml\modules\sd_models.py", line 217, in read_state_dict
    pl_sd = safetensors.torch.load_file(checkpoint_file, device=device)
  File "D:\Users\tangtang1600\Anaconda3\envs\automatic\Lib\site-packages\safetensors\torch.py", line 98, in load_file
    with safe_open(filename, framework="pt", device=device) as f:
Exception: device privateuseone:0 is invalid

 二、解决

       原因是在启动参数中使用了底运存命令--lowram,这个参数似乎会让device指向gpu,电脑是amd的集显,所以出现找不到GPU的情况。

python "F:\ai\stable_diffusion\stable-diffusion-webui-directml\webui.py" --precision full --no-half   --use-cpu all

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值