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 segfault and other errors in ForestInference.load_from_sklearn #5973

Merged
merged 6 commits into from
Jul 28, 2024

Conversation

hcho3
Copy link
Contributor

@hcho3 hcho3 commented Jul 24, 2024

Closes #5551

  • Replace np.float32 with "float32" so that we don't reference the np module. By the time __dealloc__ method is called, modules may have already been unloaded.
  • Improve the user experience by raising a helpful error when the user attempts to predict with an empty forest.

@github-actions github-actions bot added the Cython / Python Cython or Python issue label Jul 24, 2024
@dantegd dantegd added bug Something isn't working non-breaking Non-breaking change labels Jul 24, 2024
@@ -557,15 +557,15 @@ cdef class ForestInference_impl():
def __dealloc__(self):
cdef handle_t* handle_ = <handle_t*><size_t>self.handle.getHandle()
fil_dtype = self.get_dtype()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line was causing troubles, as modules may have been unloaded by the Python interpreter by the time the __dealloc__ method is called. When I inserted a print(np) statement here, it yielded None.

@hcho3 hcho3 changed the title [WIP] Fix segfault and other errors in ForestInference.load_from_sklearn Fix segfault and other errors in ForestInference.load_from_sklearn Jul 25, 2024
@hcho3 hcho3 marked this pull request as ready for review July 25, 2024 23:55
@hcho3 hcho3 requested a review from a team as a code owner July 25, 2024 23:55
@dantegd
Copy link
Member

dantegd commented Jul 28, 2024

/merge

@rapids-bot rapids-bot bot merged commit bc6f9b6 into rapidsai:branch-24.08 Jul 28, 2024
61 of 63 checks passed
@hcho3 hcho3 deleted the fix_fil branch July 28, 2024 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Cython / Python Cython or Python issue non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] calling load_from_sklearn from a ForestInference instance cause segmentationwhen predicting
2 participants