一、问题
博主用CPU硬解 Stable diffusion,sd-v1-4.ckpt能跑,但换成v1-5-pruned-emaonly.safetensors等最新格式的模型就出现Exception: device privateuseone:0 is invalid错误。文章来源:https://www.toymoban.com/news/detail-505608.html
(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的情况。文章来源地址https://www.toymoban.com/news/detail-505608.html
python "F:\ai\stable_diffusion\stable-diffusion-webui-directml\webui.py" --precision full --no-half --use-cpu all
到了这里,关于Stable diffusion加载safetensors 模型出现Exception: device privateuseone:0 is invalid的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!