Skip to content

fix(//core/conversion/conversionctx): Fix memory leak in conversionctx #376

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

Merged
merged 3 commits into from
Feb 25, 2021

Conversation

narendasan
Copy link
Collaborator

Description

Fixes a memory leak where the IHostMemory container for the produced serialized engine after conversion is not destructed properly.

h/t: @SakodaShintaro

Fixes #375

Type of change

Please delete options that are not relevant and/or add your own.

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

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes

context engine serialization

h/t: @SakodaShintaro

Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: core Issues re: The core compiler labels Feb 25, 2021
Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to Python style guidelines:

--- /workspace/py/trtorch/_compiler.py	(original)
+++ /workspace/py/trtorch/_compiler.py	(reformatted)
@@ -157,5 +157,6 @@
    build_info = "TRTorch Version: " + str(__version__) + '\n' + build_info
    return build_info

+
def set_device(gpu_id):
    trtorch._C.set_device(gpu_id)
Reformatting /workspace/py/trtorch/_compile_spec.py
Reformatting /workspace/py/trtorch/_types.py
Reformatting /workspace/py/trtorch/_compiler.py
Reformatting /workspace/py/trtorch/logging.py
Reformatting /workspace/py/trtorch/__init__.py
Reformatting /workspace/py/setup.py
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

@github-actions github-actions bot added the component: api [Python] Issues re: Python API label Feb 25, 2021
Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to Python style guidelines:

Reformatting /workspace/py/trtorch/_compile_spec.py
Reformatting /workspace/py/trtorch/_types.py
Reformatting /workspace/py/trtorch/_compiler.py
Reformatting /workspace/py/trtorch/logging.py
Reformatting /workspace/py/trtorch/__init__.py
Reformatting /workspace/py/setup.py
Reformatting /workspace/docsrc/conf.py
Reformatting /workspace/tests/modules/hub.py
--- /workspace/tests/py/test_multi_gpu.py	(original)
+++ /workspace/tests/py/test_multi_gpu.py	(reformatted)
@@ -5,7 +5,9 @@

from model_test_case import ModelTestCase

+
class TestMultiGpuSwitching(ModelTestCase):
+
    def setUp(self):
        if torch.cuda.device_count() < 2:
            self.fail("Test is not relevant for this platform since number of available CUDA devices is less than 2")
@@ -55,11 +57,13 @@
        trtorch.set_device(0)
        self.assertTrue(same < 2e-3)

+
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(TestMultiGpuSwitching.parametrize(TestMultiGpuSwitching, model=models.resnet18(pretrained=True)))

    return suite
+

suite = test_suite()

Reformatting /workspace/tests/py/model_test_case.py
Reformatting /workspace/tests/py/test_api_dla.py
Reformatting /workspace/tests/py/test_api.py
Reformatting /workspace/tests/py/test_multi_gpu.py
Reformatting /workspace/tests/py/test_to_backend_api.py
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

@github-actions github-actions bot added the component: tests Issues re: Tests label Feb 25, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@narendasan narendasan merged commit 672b863 into master Feb 25, 2021
@narendasan narendasan deleted the fix_seralization_memory_leak branch February 25, 2021 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug] Memory leak in ConversionCtx::SerializeEngine()
1 participant