[Bug]:unable to load a safetensors model: Exception: device cpu is invalid
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What happened?
Unable to load a safetensors format model. I saw some stuff in recent commits about loading them with specific features, but i'm unable to get it to load on its own at all.
Steps to reproduce the problem
switch to a safetensors model in the dropdown menu
What should have happened?
file loads
Commit where the problem happens
4af3ca5393151d61363c30eef4965e694eeac15e
What platforms do you use to access UI ?
MacOS
What browsers do you use to access the UI ?
Google Chrome
Command Line Arguments
export COMMANDLINE_ARGS="--skip-torch-cuda-test --no-half --use-cpu interrogate --api"
Additional information, context and logs
Loading weights [943793fb] from /Users/doug/Documents/diffusion/stable-diffusion-webui/models/Stable-diffusion/modelv32.safetensors
Traceback (most recent call last):
File "/Users/doug/Documents/diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/routes.py", line 284, in run_predict
output = await app.blocks.process_api(
File "/Users/doug/Documents/diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 982, in process_api
result = await self.call_function(fn_index, inputs, iterator)
File "/Users/doug/Documents/diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 824, in call_function
prediction = await anyio.to_thread.run_sync(
File "/Users/doug/Documents/diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/Users/doug/Documents/diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/Users/doug/Documents/diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "/Users/doug/Documents/diffusion/stable-diffusion-webui/modules/ui.py", line 1646, in
found a bandaid fix changing pl_sd = safetensors.torch.load_file(checkpoint_file, device=device) to pl_sd = safetensors.torch.load_file(checkpoint_file, device='cpu')
in function read_state_dict of /modules/sd_models.py made it work