-
Notifications
You must be signed in to change notification settings - Fork 612
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
Lazy loading of shared libraries. #869
Lazy loading of shared libraries. #869
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM thanks for the enhancement @gabrieldemarmiesse! @tensorflow/sig-addons-maintainers any issues with this?
self._ops = None | ||
|
||
@property | ||
def ops(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Override __getattribute__
method may a better solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fsx950223 thanks for the review! Can you expand on why it may be a better solution ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to modify the original code by this way。
For example,
return _activation_ops_so.addons_gelu(x, approximate)
Rather than
_activation_so.ops.addons_gelu(x, approximate)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean, it's clever :)
Though i'm more in favor of having explicit code rather than having smart code. It's more maintainable and readable.
LGTM |
Thanks again @gabrieldemarmiesse ! |
HI!
I got this :
|
@seanpmorgan do you have an idea of what can be causing this? |
Hmmmm this is puzzling. So as a sanity check here is a notebook using today's nightly without that issue: Could you provide the full docker image name of what you're using @AlexWang1900 . I'm thinking this is related to #987 since I see no reason this is happening from the python side (no circular import, inits look correct, etc.) I tried to test this myself but conda still doesn't have a TF2.1 version so perhaps it was built from source in this docker image. |
@seanpmorgan it is with TF2.1,so I think the docker image you can find it here: Building a new image --gpu to build an image for GPU. Running the image Run the image built locally Tensorflow custom pre-built wheel Faster build time: Building tensorflow from sources takes ~1h. Keeping this process outside the main build allows faster iterations when working on our Dockerfiles. Increase performance: When building from sources, we can leverage CPU specific optimizations |
@AlexWang1900 thanks for the info. So I tried this in a GPU kaggle kernel and did not get the same error as you did: As expected when trying to run a custom-op we get the issue in #987 issue, but importing tfa and using other parts of it should work fine. Is there something different about my kernel than yours? |
@seanpmorgan |
Fixes #855
I don't know how to make a test for that though. If possible we need to check that an so isn't loaded when doing
import tensorflow_addons
.