MohamadZeina/Disco_Diffusion_Local

No module named 'pytorch3d'

memoabuser opened this issue · 23 comments

I received those errors, and the diffuse isn't running, not really familiar with that, but I followed all the steps

image
image

Actually, I solved most of it, But i get that error now {No module named 'pytorch3d')

1- conda install -c fvcore -c iopath -c conda-forge fvcore iopath
2- conda install -c pytorch3d pytorch3d

solved the issue for me:
https://github.com/facebookresearch/pytorch3d/issues/1076#issuecomment-1043431615

it gave me different issue
ModuleNotFoundError: No module named 'py3d_tools'

solved the issue for me:
googlecolab/colabtools#2739 (comment)

thank you so much, I solved it already and troubleshooting another one now

In cell 2. Diffusion and CLIP model settings

FileNotFoundError: [Errno 2] No such file or directory: './model/secondary_model_imagenet_2.pth'

sorry am not so familiar with coding

and got this one too

  1. Diffuse!

FileNotFoundError: [Errno 2] No such file or directory: './model/512x512_diffusion_uncond_finetune_008100.pt'

you have to download them and put them in the model folder, it solved my problem:
[reddit](https://www.reddit.com/r/DiscoDiffusion/comments/uh0qg8/comment/i76awo0/?utm_source=share&utm_medium=web2x&context=3

I will try it now, thank you

I it worked good.. but now I have error once I run diffuse

CUDA error: unknown error
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

I tried the readme Instructions and it didn't work, or maybe I did something wrong -- I didn't find the resolution (128x128) line in settings

NVIDIA GeForce RTX 3070
32 GB Ram
Fresh reboot

try with a very simple prompt with just ViTB32 to true

ViTB32 = True #@param{type:"boolean"}
ViTB16 = False #@param{type:"boolean"}
ViTL14 = False #@param{type:"boolean"} # Default False
RN101 = False #@param{type:"boolean"} # Default False
RN50 = False #@param{type:"boolean"} # Default True
RN50x4 = False #@param{type:"boolean"} # Default False
RN50x16 = False #@param{type:"boolean"}
RN50x64 = False #@param{type:"boolean"}
SLIPB16 = False # param{type:"boolean"} # Default False. Looks broken, likely related to commented import of SLIP_VITB16
SLIPL16 = False # param{type:"boolean"}

image

RuntimeError Traceback (most recent call last)
Input In [45], in <cell line: 153>()
151 print(diffusion_model_path)
152 model.load_state_dict(torch.load(diffusion_model_path, map_location='cpu'))
--> 153 model.requires_grad_(False).eval().to(device)
154 for name, param in model.named_parameters():
155 if 'qkv' in name or 'norm' in name or 'proj' in name:

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:899, in Module.to(self, *args, **kwargs)
895 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None,
896 non_blocking, memory_format=convert_to_format)
897 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
--> 899 return self._apply(convert)

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:570, in Module._apply(self, fn)
568 def _apply(self, fn):
569 for module in self.children():
--> 570 module._apply(fn)
572 def compute_should_use_set_data(tensor, tensor_applied):
573 if torch._has_compatible_shallow_copy_type(tensor, tensor_applied):
574 # If the new tensor has compatible tensor type as the existing tensor,
575 # the current behavior is to change the tensor in-place using .data =,
(...)
580 # global flag to let the user control whether they want the future
581 # behavior of overwriting the existing tensor or not.

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:570, in Module._apply(self, fn)
568 def _apply(self, fn):
569 for module in self.children():
--> 570 module._apply(fn)
572 def compute_should_use_set_data(tensor, tensor_applied):
573 if torch._has_compatible_shallow_copy_type(tensor, tensor_applied):
574 # If the new tensor has compatible tensor type as the existing tensor,
575 # the current behavior is to change the tensor in-place using .data =,
(...)
580 # global flag to let the user control whether they want the future
581 # behavior of overwriting the existing tensor or not.

[... skipping similar frames: Module._apply at line 570 (2 times)]

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:570, in Module._apply(self, fn)
568 def _apply(self, fn):
569 for module in self.children():
--> 570 module._apply(fn)
572 def compute_should_use_set_data(tensor, tensor_applied):
573 if torch._has_compatible_shallow_copy_type(tensor, tensor_applied):
574 # If the new tensor has compatible tensor type as the existing tensor,
575 # the current behavior is to change the tensor in-place using .data =,
(...)
580 # global flag to let the user control whether they want the future
581 # behavior of overwriting the existing tensor or not.

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:593, in Module._apply(self, fn)
589 # Tensors stored in modules are graph leaves, and we don't want to
590 # track autograd history of param_applied, so we have to use
591 # with torch.no_grad():
592 with torch.no_grad():
--> 593 param_applied = fn(param)
594 should_use_set_data = compute_should_use_set_data(param, param_applied)
595 if should_use_set_data:

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:897, in Module.to..convert(t)
894 if convert_to_format is not None and t.dim() in (4, 5):
895 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None,
896 non_blocking, memory_format=convert_to_format)
--> 897 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)

RuntimeError: CUDA error: unknown error
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

still giving the same error

I didn't have that error

yeah ok ,now I got it.
I made a New file in the note book and I copied and pasted all the cells there as the original one is read only.

How did you solve the Permission denied???

I solved this issue by put the jupyter notebook in root folder of the repo

image

RuntimeError Traceback (most recent call last) Input In [45], in <cell line: 153>() 151 print(diffusion_model_path) 152 model.load_state_dict(torch.load(diffusion_model_path, map_location='cpu')) --> 153 model.requires_grad_(False).eval().to(device) 154 for name, param in model.named_parameters(): 155 if 'qkv' in name or 'norm' in name or 'proj' in name:

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:899, in Module.to(self, *args, **kwargs) 895 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, 896 non_blocking, memory_format=convert_to_format) 897 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) --> 899 return self._apply(convert)

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:570, in Module._apply(self, fn) 568 def _apply(self, fn): 569 for module in self.children(): --> 570 module._apply(fn) 572 def compute_should_use_set_data(tensor, tensor_applied): 573 if torch._has_compatible_shallow_copy_type(tensor, tensor_applied): 574 # If the new tensor has compatible tensor type as the existing tensor, 575 # the current behavior is to change the tensor in-place using .data =, (...) 580 # global flag to let the user control whether they want the future 581 # behavior of overwriting the existing tensor or not.

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:570, in Module._apply(self, fn) 568 def _apply(self, fn): 569 for module in self.children(): --> 570 module._apply(fn) 572 def compute_should_use_set_data(tensor, tensor_applied): 573 if torch._has_compatible_shallow_copy_type(tensor, tensor_applied): 574 # If the new tensor has compatible tensor type as the existing tensor, 575 # the current behavior is to change the tensor in-place using .data =, (...) 580 # global flag to let the user control whether they want the future 581 # behavior of overwriting the existing tensor or not.

[... skipping similar frames: Module._apply at line 570 (2 times)]

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:570, in Module._apply(self, fn) 568 def _apply(self, fn): 569 for module in self.children(): --> 570 module._apply(fn) 572 def compute_should_use_set_data(tensor, tensor_applied): 573 if torch._has_compatible_shallow_copy_type(tensor, tensor_applied): 574 # If the new tensor has compatible tensor type as the existing tensor, 575 # the current behavior is to change the tensor in-place using .data =, (...) 580 # global flag to let the user control whether they want the future 581 # behavior of overwriting the existing tensor or not.

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:593, in Module._apply(self, fn) 589 # Tensors stored in modules are graph leaves, and we don't want to 590 # track autograd history of param_applied, so we have to use 591 # with torch.no_grad(): 592 with torch.no_grad(): --> 593 param_applied = fn(param) 594 should_use_set_data = compute_should_use_set_data(param, param_applied) 595 if should_use_set_data:

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/nn/modules/module.py:897, in Module.to..convert(t) 894 if convert_to_format is not None and t.dim() in (4, 5): 895 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, 896 non_blocking, memory_format=convert_to_format) --> 897 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)

RuntimeError: CUDA error: unknown error CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

Every time I have an unknown problem restarting the ubuntu session and starting all the cells works for me.
Do you have tried with 512 * 512 models ?
Because i don't know if the 256 * 256 are downloaded too and put in model folder like 512 * 512

But for debugging ->
"Could you run your code with the CUDA_LAUNCH_BLOCKING=1 env variable and post the new stack trace please.
You can do that by running CUDA_LAUNCH_BLOCKING=1 python your_script.py."
Sauce

Ps: I run this repo with RTX3070 too without probleme

how did you do it, Because I have the 256256 model downloaded and the 512512, I tried both and still having the same problem

how did you do it, Because I have the 256_256 model downloaded and the 512_512, I tried both and still having the same problem

I don't know the only difference I see is that I have another version of cuda mine is 11.3 and python 3.8. But I doubt that is the problem.
What is the size of the image chosen? I am in [800, 450]

and try with prompt very simple like
[0: "a red boat"]

Thank you, actually it worked after I changed the size into 800.450
is there no other way to increase the image size ?

not me too, I just changed the image size in the settings cell

solved the issue for me: googlecolab/colabtools#2739 (comment)

I've gotten as far as this, but now I get this error.
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

Using downloaded and verified file: ./model/superres/project.yaml/?dl=1
Using downloaded and verified file: ./model/superres/last.ckpt/?dl=1
Loading model from ./model/superres/last.ckpt/?dl=1
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [11], in <cell line: 434>()
    431     return log
    433 sr_diffMode = 'superresolution'
--> 434 sr_model = get_model('superresolution')
    436 def do_superres(img, filepath):
    438   if args.sharpen_preset == 'Faster':

Input In [11], in get_model(mode)
    213 path_conf, path_ckpt = download_models(mode)
    214 config = OmegaConf.load(path_conf)
--> 215 model, step = load_model_from_config(config, path_ckpt)
    216 return model

Input In [11], in load_model_from_config(config, ckpt)
    200 def load_model_from_config(config, ckpt):
    201     print(f"Loading model from {ckpt}")
--> 202     pl_sd = torch.load(ckpt, map_location="cpu")
    203     global_step = pl_sd["global_step"]
    204     sd = pl_sd["state_dict"]

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/serialization.py:600, in load(f, map_location, pickle_module, **pickle_load_args)
    595 if _is_zipfile(opened_file):
    596     # The zipfile reader is going to advance the current file position.
    597     # If we want to actually tail call to torch.jit.load, we need to
    598     # reset back to the original position.
    599     orig_position = opened_file.tell()
--> 600     with _open_zipfile_reader(opened_file) as opened_zipfile:
    601         if _is_torchscript_zip(opened_zipfile):
    602             warnings.warn("'torch.load' received a zip file that looks like a TorchScript archive"
    603                           " dispatching to 'torch.jit.load' (call 'torch.jit.load' directly to"
    604                           " silence this warning)", UserWarning)

File ~/anaconda3/envs/pytorch_110/lib/python3.9/site-packages/torch/serialization.py:242, in _open_zipfile_reader.__init__(self, name_or_buffer)
    241 def __init__(self, name_or_buffer) -> None:
--> 242     super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))

RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

Any idea why this would happen? Read someone who said it is due to an incomplete download, but no idea how true that is.

Closing this as the initial issue is fixed - needed to install pytorch3d.

If you haven’t fixed this other problem feel free to open a new issue. That said - I’ve had similar issues with incomplete or corrupted models, try just deleting them and downloading again (they’re big, be patient)