Code Monkey home page Code Monkey logo

Comments (1)

yingchingl avatar yingchingl commented on August 23, 2024

Additional Debugging

When running the test program with PYTHONMALLOC=debug environment variable, Python will check the status of the GIL when performing memory allocation and deallocation:

PYTHONMALLOC=debug python sdxl_onediff_test.py

The captured stack trace is as follows:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000072fcf0ac7859 in __GI_abort () at abort.c:79
#2  0x00000000004a6ef3 in fatal_error_exit (status=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>) at /usr/local/src/conda/python-3.10.13/Python/pylifecycle.c:2556
#3  fatal_error (fd=<optimized out>, header=header@entry=1, prefix=prefix@entry=0x6b6a90 <__func__.5.lto_priv.0> "_PyMem_DebugFree", msg=msg@entry=0x627e68 "Python memory allocator called without holding the GIL", status=status@entry=-1) at /usr/local/src/conda/python-3.10.13/Python/pylifecycle.c:2667
#4  0x00000000004a727d in _Py_FatalErrorFunc (func=func@entry=0x6b6a90 <__func__.5.lto_priv.0> "_PyMem_DebugFree", msg=msg@entry=0x627e68 "Python memory allocator called without holding the GIL") at /usr/local/src/conda/python-3.10.13/Python/pylifecycle.c:2753
#5  0x0000000000423122 in _PyMem_DebugCheckGIL (func=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>) at /usr/local/src/conda/python-3.10.13/Objects/obmalloc.c:2646
#6  0x00000000004dd024 in _PyMem_DebugFree (ctx=0x743040 <_PyMem_Debug+96>, ptr=0x72f37c77f4c0) at /usr/local/src/conda/python-3.10.13/Objects/obmalloc.c:2670
#7  0x000072f57c11946c in ?? () from /opt/conda/lib/python3.10/site-packages/oneflow/_oneflow_internal.cpython-310-x86_64-linux-gnu.so
#8  0x000072f45e27ec0d in std::_Sp_counted_ptr_inplace<oneflow::one::LocalTensor, std::allocator<oneflow::one::LocalTensor>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() () from /opt/conda/lib/python3.10/site-packages/oneflow/../oneflow.libs/liboneflow-d0782696.so
#9  0x000072f57c097a1a in oneflow::deleter(DLManagedTensor*) () from /opt/conda/lib/python3.10/site-packages/oneflow/_oneflow_internal.cpython-310-x86_64-linux-gnu.so
#10 0x000072fc54ddb28c in c10::deleteInefficientStdFunctionContext(void*) () from /opt/conda/lib/python3.10/site-packages/torch/lib/libc10.so
#11 0x000072fcbf9bb7b6 in c10::StorageImpl::~StorageImpl() () from /opt/conda/lib/python3.10/site-packages/torch/lib/libtorch_python.so
#12 0x000072fc54e02ca7 in c10::intrusive_ptr<c10::StorageImpl, c10::detail::intrusive_target_default_null_type<c10::StorageImpl> >::reset_() () from /opt/conda/lib/python3.10/site-packages/torch/lib/libc10.so
#13 0x000072fc54dfacb3 in c10::TensorImpl::~TensorImpl() () from /opt/conda/lib/python3.10/site-packages/torch/lib/libc10.so
#14 0x000072fc54dfae49 in c10::TensorImpl::~TensorImpl() () from /opt/conda/lib/python3.10/site-packages/torch/lib/libc10.so
#15 0x000072fcbfc6b738 in THPVariable_clear(THPVariable*) () from /opt/conda/lib/python3.10/site-packages/torch/lib/libtorch_python.so
#16 0x000072fcbfc6bac5 in THPVariable_subclass_dealloc(_object*) () from /opt/conda/lib/python3.10/site-packages/torch/lib/libtorch_python.so
#17 0x00000000004dd8e4 in _Py_Dealloc (op=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>) at /usr/local/src/conda/python-3.10.13/Objects/object.c:2295
#18 _Py_DECREF (op=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>) at /usr/local/src/conda/python-3.10.13/Include/object.h:500
#19 _Py_XDECREF (op=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>) at /usr/local/src/conda/python-3.10.13/Include/object.h:567
#20 list_dealloc (op=0x72f37c78b200) at /usr/local/src/conda/python-3.10.13/Objects/listobject.c:355
#21 0x00000000004f1820 in _Py_Dealloc (op=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>) at /usr/local/src/conda/python-3.10.13/Objects/object.c:2295
#22 _Py_DECREF (op=<optimized out>) at /usr/local/src/conda/python-3.10.13/Include/object.h:500
#23 _Py_XDECREF (op=<optimized out>) at /usr/local/src/conda/python-3.10.13/Include/object.h:567
#24 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=Frame 0x6c043530, for file /opt/conda/lib/python3.10/site-packages/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py, line 1100, in __call__ (self=<StableDiffusionXLControlNetPipeline(_internal_dict=<FrozenDict(vae=('diffusers', 'AutoencoderKL'), text_encoder=('onediff', 'MixedOneflowDeployableModule'), text_encoder_2=('onediff', 'MixedOneflowDeployableModule'), tokenizer=('transformers', 'CLIPTokenizer'), tokenizer_2=('transformers', 'CLIPTokenizer'), unet=('onediff', 'MixedOneflowDeployableModule'), controlnet=('onediff', 'MixedOneflowDeployableModule'), scheduler=('diffusers', 'EulerDiscreteScheduler'), force_zeros_for_empty_prompt=True, _name_or_path='stabilityai/stable-diffusion-xl-base-1.0', _FrozenDict__frozen=True) at remote 0x72f8b83427b0>, vae=<AutoencoderKL(_internal_dict=<FrozenDict(in_channels=3, out_channels=3, down_block_types=['DownEncoderBlock2D', 'DownEncoderBlock2D', 'DownEncoderBlock2D', 'DownEncoderBlock2D'], up_block_types=['UpDecoderBlock2D', 'UpDecoderBlock2D', 'UpDecoderBloc...(truncated), throwflag=<optimized out>) at /usr/local/src/conda/python-3.10.13/Python/ceval.c:1882

This reveals that the Python memory allocator is being called without holding the GIL.

from onediff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.