lllyasviel / lllyasviel/ControlNet

Error when running python gradio_canny2image.py

Open
#308 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
34.1k
Forks
3k
PR merge metrics
No merged PRs in 30d

Description

I have download all of the models/annotators and put them in their proper folders, but when I try to run python gradio_canny2image.py I get the error below:

(control) me@me-MBP ControlNet % python gradio_canny2image.py logging improved. No module 'xformers'. Proceeding without it. ControlLDM: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. making attention of type 'vanilla' with 512 in_channels Working with z of shape (1, 4, 32, 32) = 4096 dimensions. making attention of type 'vanilla' with 512 in_channels Loaded model config from [./models/cldm_v15.yaml] Traceback (most recent call last): File "gradio_canny2image.py", line 21, in <module> model.load_state_dict(load_state_dict('./models/control_sd15_canny.pth', location='cuda')) File "/~/Desktop/repos/personal/ControlNet/cldm/model.py", line 18, in load_state_dict state_dict = get_state_dict(torch.load(ckpt_path, map_location=torch.device(location))) File "/~/anaconda3/envs/control/lib/python3.8/site-packages/torch/serialization.py", line 712, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "/~/anaconda3/envs/control/lib/python3.8/site-packages/torch/serialization.py", line 1049, in _load result = unpickler.load() File "/~/anaconda3/envs/control/lib/python3.8/site-packages/torch/serialization.py", line 1019, in persistent_load load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location)) File "/~/anaconda3/envs/control/lib/python3.8/site-packages/torch/serialization.py", line 1001, in load_tensor wrap_storage=restore_location(storage, location), File "/~/anaconda3/envs/control/lib/python3.8/site-packages/torch/serialization.py", line 973, in restore_location return default_restore_location(storage, str(map_location)) File "/~/anaconda3/envs/control/lib/python3.8/site-packages/torch/serialization.py", line 175, in default_restore_location result = fn(storage, location) File "/~/anaconda3/envs/control/lib/python3.8/site-packages/torch/serialization.py", line 152, in _cuda_deserialize device = validate_cuda_device(location) File "/~/anaconda3/envs/control/lib/python3.8/site-packages/torch/serialization.py", line 136, in validate_cuda_device raise RuntimeError('Attempting to deserialize object on a CUDA ' RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with gradio_canny2image.py line 21 and follow the checkpoint-loading call into cldm/model.py line 18. Reproduce the command in the reported environment, inspect how the checkpoint is mapped when CUDA is unavailable, and verify that loading no longer raises the reported torch CUDA deserialization error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.