示例#1
0
def profile():
    """Enable CUDA profiling during with statement.

    This function enable profiling on entering with statement, and disable
    profiling on leaving the statement.

    >>> with cupy.cuda.profile():
    ...    # do something you want to measure

    """
    profiler.start()
    try:
        yield
    finally:
        profiler.stop()
示例#2
0
文件: __init__.py 项目: toslunar/cupy
def profile():
    """Enable CUDA profiling during with statement.

    This function enables profiling on entering a with statement, and disables
    profiling on leaving the statement.

    >>> with cupyx.profiler.profile():
    ...    # do something you want to measure
    ...    pass

    .. note::
        When starting ``nvprof`` from the command line, manually setting
        ``--profile-from-start off`` may be required for the desired behavior.
        Likewise, when using ``nsys profile`` setting ``-c cudaProfilerApi``
        may be required.

    .. seealso:: :func:`cupy.cuda.profiler.start`,
        :func:`cupy.cuda.profiler.stop`
    """
    _profiler.start()
    try:
        yield
    finally:
        _profiler.stop()