Skip to content

[BUG] Debug logger breaks during cuda.jit call when debugger was called before #454

@ZzEeKkAa

Description

@ZzEeKkAa

Describe the bug

Debug logger breaks during cuda.jit call when debugger was called before

Steps/Code to reproduce bug

import numpy as np
from numba import cuda
import logging

logging.getLogger().setLevel(logging.DEBUG)


def main():
    logging.info("Start") # <- without this everything works

    @cuda.jit
    def f(a):
        a[0]=0

    a = np.zeros(1,dtype=np.float32)
    f[1, 1](a)


if __name__ == "__main__":
    main()

Results in an error log:

DEBUG:numba.core.byteflow:----------------------DONE Prune PHIs-----------------------
DEBUG:numba.core.byteflow:block_infos State(pc_initial=0 nstack_initial=0):
AdaptBlockInfo(insts=((0, {}), (2, {}), (4, {'res': '$const4.0.1'}), (6, {'res': '$a6.1'}), (8, {'res': '$const8.2.1'}), (10, {'target': '$a6.1', 'index': '$const8.2.1', 'value': '$const4.0.1'}), (12, {}), (14, {'res': '$const14.3.0'}), (16, {'retval': '$const14.3.0', 'castval': '$16return_value.4'})), outgoing_phis={}, blockstack=(), active_try_block=None, outgoing_edgepushed={})
--- Logging error ---
Traceback (most recent call last):
  File "/local/home/yhavrylko/opt/lib/python3.11/logging/__init__.py", line 1110, in emit
    msg = self.format(record)
          ^^^^^^^^^^^^^^^^^^^
  File "/local/home/yhavrylko/opt/lib/python3.11/logging/__init__.py", line 953, in format
    return fmt.format(record)
           ^^^^^^^^^^^^^^^^^^
  File "/local/home/yhavrylko/opt/lib/python3.11/logging/__init__.py", line 687, in format
    record.message = record.getMessage()
                     ^^^^^^^^^^^^^^^^^^^
  File "/local/home/yhavrylko/opt/lib/python3.11/logging/__init__.py", line 375, in getMessage
    msg = str(self.msg)
          ^^^^^^^^^^^^^
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/utils.py", line 788, in __str__
    return pformat(*self.args, **self.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: pformat() got an unexpected keyword argument 'lazy_func'
Call stack:
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/nvmath-python/./examples/device/cublasdx_simple_gemm_fp32.py", line 22, in <module>
    f[1, 1](a)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/dispatcher.py", line 700, in __call__
    return self.dispatcher.call(
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/dispatcher.py", line 1022, in call
    kernel = _dispatcher.Dispatcher._cuda_call(self, *args)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/dispatcher.py", line 1030, in _compile_for_args
    return self.compile(tuple(argtypes))
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba/src/numba/core/compiler_lock.py", line 35, in _acquire_compile_lock
    return func(*args, **kwargs)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/dispatcher.py", line 1296, in compile
    kernel = _Kernel(self.py_func, argtypes, **self.targetoptions)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba/src/numba/core/compiler_lock.py", line 35, in _acquire_compile_lock
    return func(*args, **kwargs)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/dispatcher.py", line 145, in __init__
    cres = compile_cuda(
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba/src/numba/core/compiler_lock.py", line 35, in _acquire_compile_lock
    return func(*args, **kwargs)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/compiler.py", line 745, in compile_cuda
    cres = compile_extra(
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/compiler.py", line 586, in compile_extra
    return pipeline.compile_extra(func)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/core/compiler.py", line 124, in compile_extra
    return self._compile_bytecode()
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/core/compiler.py", line 192, in _compile_bytecode
    return self._compile_core()
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/core/compiler.py", line 160, in _compile_core
    pm.run(self.state)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/core/compiler_machinery.py", line 384, in run
    self._runPass(idx, pass_inst, state)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba/src/numba/core/compiler_lock.py", line 35, in _acquire_compile_lock
    return func(*args, **kwargs)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/core/compiler_machinery.py", line 336, in _runPass
    mutated |= check(pss.run_pass, internal_state)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/core/compiler_machinery.py", line 290, in check
    mangled = func(compiler_state)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/compiler.py", line 497, in run_pass
    func_ir = interp.interpret(bc)
  File "/home/scratch.yhavrylko_ent/Projects/nvidia/numba-cuda/numba_cuda/numba/cuda/core/interpreter.py", line 1431, in interpret
    _logger.debug(
Message: <numba.cuda.utils._lazy_pformat object at 0x7f7e0b5c1790>
Arguments: ()
DEBUG:numba.cuda.core.ssa:==== SSA block analysis pass on 0

Expected behavior

Works without error log

Environment details (please complete the following information):

  • Environment location: Bare-metal, n/a
  • Method of numba-cuda install: from source, pip, n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions