latent-diffusion icon indicating copy to clipboard operation
latent-diffusion copied to clipboard

segfault with knn2img.py

Open salamanders opened this issue 3 years ago • 16 comments

Trying the sample on a barebones fresh Ubuntu Server install.

python scripts/knn2img.py  --prompt "a happy bear reading a newspaper, oil on canvas"

results in Segmentation fault (core dumped)

[ 3634.730226] python[2030]: segfault at 300000004 ip 00007f22e62442e6 sp 00007fff04937560 error 4 in _message.cpython-38-x86_64-linux-gnu.so[7f22e622d000+14e000]
[ 3634.730241] Code: 54 49 89 fc 55 31 ed 53 48 83 ec 10 eb 10 66 0f 1f 44 00 00 83 c5 01 41 39 6c 24 04 7e 5f 48 63 dd 48 c1 e3 05 49 03 5c 24 28 <48> 63 7b 04 e8 91 f3 fe ff 48 89 44 24 08 48 89 c2 48 85 c0 74 5f

Happy to provide whatever to help. Understand that it is likely an underlying issue and not something this project specfic.

salamanders avatar Aug 10 '22 20:08 salamanders

Having the same issue here.

PhazonJim avatar Aug 13 '22 13:08 PhazonJim

Same here, except I only get "Segmentation fault"

KobeAmerijckxPT avatar Aug 16 '22 09:08 KobeAmerijckxPT

@PhazonJim @KobeAmerijckxPT are you able to run the other demos? I'm not because I don't have a working graphics card, and there is a bug where it should route to the CPU but doesn't in all cases. https://github.com/CompVis/latent-diffusion/issues/118

salamanders avatar Aug 16 '22 17:08 salamanders

Same Segmentation fault (core dumped) issue, and it may comes from package scann.

kuri-leo avatar Aug 17 '22 07:08 kuri-leo

Ditto. Here's the tail of the verbose output.

# /home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/__pycache__/descriptor.cpython-38.pyc matches /home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/descriptor.py
# code object from '/home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/__pycache__/descriptor.cpython-38.pyc'
# /home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/internal/__pycache__/__init__.cpython-38.pyc matches /home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/internal/__init__.py
# code object from '/home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/internal/__pycache__/__init__.cpython-38.pyc'
import 'google.protobuf.internal' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc1a1a0a310>
# /home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/internal/__pycache__/api_implementation.cpython-38.pyc matches /home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/internal/api_implementation.py
# code object from '/home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/internal/__pycache__/api_implementation.cpython-38.pyc'
# extension module 'google.protobuf.internal._api_implementation' loaded from '/home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/internal/_api_implementation.cpython-38-x86_64-linux-gnu.so'
# extension module 'google.protobuf.internal._api_implementation' executed from '/home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/internal/_api_implementation.cpython-38-x86_64-linux-gnu.so'
import 'google.protobuf.internal._api_implementation' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc1a1a0a910>
import 'google.protobuf.internal.api_implementation' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc1a1a0a4c0>
# /home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/pyext/__pycache__/__init__.cpython-38.pyc matches /home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/pyext/__init__.py
# code object from '/home/kadah/anaconda3/envs/ldm2/lib/python3.8/site-packages/google/protobuf/pyext/__pycache__/__init__.cpython-38.pyc'
import 'google.protobuf.pyext' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc1a1a0a7c0>
Segmentation fault (core dumped)

Swapping to torch for cuda 11.6 (which allowed the other examples to run) had no effect.

Kadah avatar Aug 17 '22 07:08 Kadah

Hi folks, I just achieved to run this by install scann seperately, you may have a try. Good luck!

kuri-leo avatar Aug 18 '22 07:08 kuri-leo

I have this error as well, running on a 3090 RTX in Ubuntu. @kuri-leo pip uninstalling scann and installing did not do it for me, unfortunately. txt2img-large model works fine though.

ghost avatar Aug 19 '22 00:08 ghost

I have this error as well, running on a 3090 RTX in Ubuntu. @kuri-leo pip uninstalling scann and installing did not do it for me, unfortunately. txt2img-large model works fine though.

Hi @palexpereira , sorry to hear that. My steps are :

  1. install conda dependency
conda env create -f environment.yaml
conda activate ldm
  1. install transformer pip install transformers==4.19.2
  2. install kornia pip install kornia==0.6.4
  3. install torchmetrics pip install torchmetrics==0.6.0
  4. install einops pip install git+https://github.com/arogozhnikov/einops.git
  5. finally, install scann seperately pip install scann

kuri-leo avatar Aug 19 '22 02:08 kuri-leo

@kuri-leo unfortunately, same as the others - I did the exact same install steps you listed, and still get a segfault. I think your issue may be a different one?

salamanders avatar Aug 19 '22 23:08 salamanders

@kuri-leo thanks for the help, but unfortunately it did not work. all these requirements were already satisfied

ghost avatar Aug 20 '22 01:08 ghost

I moved the import scann call to the beginning of knn2img.py and the segmentation fault didn't occur. I don't know why that worked!

ideoscopic avatar Aug 20 '22 02:08 ideoscopic

@Chreod me too, bizarre!

salamanders avatar Aug 20 '22 04:08 salamanders

@kuri-leo thanks for the help, but unfortunately it did not work. all these requirements were already satisfied

That's pretty strange... I did install them seperately as well as add two print before and behind ‘import scann’ to locate the issue. This way works for me.

At least, try Chreod's solution to at least make it work

kuri-leo avatar Aug 20 '22 05:08 kuri-leo

I manager to get it to work by recreating the env a few times till I accidentally forgot to install the documented additional package and went about manually resolving the missing packages instead. I do not know the exact recipe that ended working, but the main different was using current repo versions of several. Here's my conda ldm env. conda.txt

Kadah avatar Aug 20 '22 22:08 Kadah

I moved the import scann call to the beginning of knn2img.py and the segmentation fault didn't occur. I don't know why that worked!

Hello, just came here to say that this solved my problem, thanks.

khorchanov avatar Aug 24 '22 11:08 khorchanov

I moved the import scann call to the beginning of knn2img.py and the segmentation fault didn't occur. I don't know why that worked!

This works! So curious why simply changing the order will help.

ZN-Qiao avatar Oct 07 '22 00:10 ZN-Qiao