Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exit sequence. #5138

Merged
merged 8 commits into from
Nov 3, 2023
Merged

Fix exit sequence. #5138

merged 8 commits into from
Nov 3, 2023

Conversation

mzient
Copy link
Contributor

@mzient mzient commented Nov 2, 2023

Register a python atexit handler that shuts down the pipelines.
Fix host resource cleanup.
Improve Pipeline shutdown sequence; ensure that memory resources are ready when the pipeline is created

Category:

Bug fix (non-breaking change which fixes an issue)

Description:

The bug: when using PythonFunction operator, the shutdown sequence was somehow broken and the pipeline was still running when the interpreter was already torn down and some libraries were unloaded.

The fix:
Register a python atexit handler that shuts down the pipelines.
Fix host resource cleanup.
Improve Pipeline shutdown sequence; ensure that memory resources are ready when the pipeline is created
Additionally (I don't know how necessary this is, after all) - got rid of static variables when creating host default resource.

Additional information:

Affected modules and functionalities:

Pipeline (C++ and Python)
Default resources.

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: DALI-3673

… that memory resources are ready when the pipeline is created; Register a python atexit handler that shuts down the pipelines.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@mzient mzient added the important-fix Fixes an important issue in the software or development environment. label Nov 2, 2023
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10556356]: BUILD STARTED

@JanuszL JanuszL self-assigned this Nov 2, 2023
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10556871]: BUILD STARTED

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10556906]: BUILD STARTED

dali/pipeline/pipeline.h Outdated Show resolved Hide resolved
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Comment on lines 23 to 27
def test_shutdown():
global p
p = pipeline(device_id=None)
p.build()
p.run()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test case fail without the fix? If not, maybe some better test would be suitable?

Copy link
Contributor Author

@mzient mzient Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't "fail". The script crashes at exit.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10557658]: BUILD STARTED

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10557763]: BUILD STARTED

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10559980]: BUILD STARTED

Comment on lines +1506 to +1509
if p is None:
Pipeline._pipes.discard(weak)
continue
p._shutdown()
Copy link
Contributor

@JanuszL JanuszL Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will that work as well?

Suggested change
if p is None:
Pipeline._pipes.discard(weak)
continue
p._shutdown()
if p is not None:
p._shutdown()

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [10559980]: BUILD PASSED

@mzient mzient merged commit 31c7791 into NVIDIA:main Nov 3, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
important-fix Fixes an important issue in the software or development environment.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants