compiler self.module deletion bug fix #59
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Within the runner class, self.module is kept as a weakref. We do this to be able to delete the uncompiled model form the GPU when we have the compiled model.
However something interesting can happen if a user's compilation script finishes before compilation is completed. The user script will wait until compilation is done. However, if it's been a while since a non-compiled inference call was made, python's garbage collector will see that there are no strong references to self.module, and it will thus delete the object.
So, when compilation does finish and it calls
del self.moduleto delete the uncompiled module, it tries to access something that doesn't exist and throws an error. This PR will prevent this bad accessNOTE: The behaviour of not exiting an inference script because compilation is done is something we want to avoid: see this issue