-
Notifications
You must be signed in to change notification settings - Fork 1
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
52 gpu utilization #58
Conversation
src/veriflow/flows.py
Outdated
class Flow(torch.nn.Module): | ||
"""Base implementation of a flow model""" | ||
|
||
# Export mode determines whether the log_prob or the sample function is exported to onnx | ||
export_modes = Literal["log_prob", "sample"] | ||
export: export_modes = "log_prob" | ||
device = "cpu" | ||
device = "cuda" |
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.
Is this field "device" used somewhere?
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.
The class variable acts as a default value in case the someone accesses the device before calling to
obj = Flow(...)
obj.device
Since strings are immutable, the class variable cannot be changed and the instance variable "device" is created when someone sets the device variable. As soon as that happens the instance variable has precedence over the class variable.
In case that you are not familiar with class variables, have a look into this post
Anyway, this assumes that the initial location is always cpu. It is probably better to have it as another instantiation argument with default value "cpu". Then you can change the value in the config file.
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.
Thanks for the explanation. I was wondering indeed why then we need to pass it as an argument of the fit method. I get now that is the variable we set also in the config when creating the Flow object, if I am not mistaken.
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.
Looks good. I only saw that there where two potentially unnecessary casts to torch.Tensor. Could be that this causes some unnecessary copying.
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.
Thanks great improvement!
Summary:
- On MNIST3 with batch size of 128 GPU utilization
- Mostly between 50% - 70%
- Some sudden short drops to 1% (after epoch?)
- Hence, problem (mostly) solved
PR related to the issue #52
CUDA utilization now reaches 70% max. It still drops to 10% for some operations.
Changes made: