Replace Variable.volatile with torch.no_grad()#3970
Replace Variable.volatile with torch.no_grad()#3970colesbury merged 11 commits intopytorch:masterfrom
Conversation
|
@colesbury, thanks for your PR! We identified @zdevito to be a potential reviewer. |
|
I placed the context manage in the |
f819873 to
7dcd69a
Compare
|
Haven't started the review, but can we please call it |
Gradients were becoming non-volatile because at::zeros_like returned a Variable with volatile always set to false. The non-volatile gradients accumulated history in the model which results in continuously increasing memory usage, See pytorch#3983, pytorch#3835, pytorch#3824 In v0.4 this will be more robustly solved by pytorch#3970
Gradients were becoming non-volatile because at::zeros_like returned a Variable with volatile always set to false. The non-volatile gradients accumulated history in the model which results in continuously increasing memory usage, See #3983, #3835, #3824 In v0.4 this will be more robustly solved by #3970
Gradients were becoming non-volatile because at::zeros_like returned a Variable with volatile always set to false. The non-volatile gradients accumulated history in the model which results in continuously increasing memory usage, See pytorch#3983, pytorch#3835, pytorch#3824 In v0.4 this will be more robustly solved by pytorch#3970
Gradients were becoming non-volatile because at::zeros_like returned a Variable with volatile always set to false. The non-volatile gradients accumulated history in the model which results in continuously increasing memory usage, See #3983, #3835, #3824 In v0.4 this will be more robustly solved by #3970
|
ping |
apaszke
left a comment
There was a problem hiding this comment.
Looks great. I have a ton of questions, because I want to make sure that everything works fine, and we haven't missed anything. Also, I think there are a few things that should be fixed before we merge this.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
bc4bd95 to
4968993
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
apaszke
left a comment
There was a problem hiding this comment.
Can you please add a test that checks that views of a detached base still require grad and have grad functions?
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This removes volatile from Variable. The functionality is mostly replaced by a global (thread-local) flag, which is controlled by torch.set_backprop_enabled() and the context manager torch.no_backprop(). Fixes pytorch#3627
rebase_history also now immediately updates view._grad_fn.
d5fa2c1 to
1efda85
Compare
| base.output_nr() = 0; | ||
| base.get()->_grad_fn = std::make_shared<CopySlices>( | ||
| base, TensorGeometry(data), std::move(grad_fn)); | ||
| get_grad_fn(); // trigger an update to the view's grad_fn |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Can we update the documentation highlighting the removal of volatile in favor of torch.no_grad( )? |
|
@rawalkhirodkar yes, that's definitely needed. Can you please send a PR? |
|
Also I'm not sure what to do if only part of variables don't require grads |
|
@Randl |
|
@apaszke I probably didn't explain myself well. As far as I understand, |
|
Then you need to separate the volatile codepaths from the other ones. I haven't yet seen a case where keeping only some Variables volatile is useful. |
|
@Randl also note that volatile variables propagate in the graph. So if you have 2 variables, |
|
hello,i want to know that if PyTorch 0.4 can with CUDA7.5 support.cause when i install cuda8.0,it show:" Found GPU1 Quadro K2000 which is of cuda capability 3.0. |
Gradients were becoming non-volatile because at::zeros_like returned a Variable with volatile always set to false. The non-volatile gradients accumulated history in the model which results in continuously increasing memory usage, See pytorch#3983, pytorch#3835, pytorch#3824 In v0.4 this will be more robustly solved by pytorch#3970
This removes volatile from Variable. The functionality is mostly replaced by a global (thread-local) flag, which is controlled by torch.set_grad_enabled() and the context manager torch.no_grad(). In C++, the flag is exposed through GradMode::is_enabled() and GradMode::set_enabled() Fixes pytorch#3627
This removes volatile from Variable. The functionality is mostly
replaced by a global (thread-local) flag, which is controlled by
torch.set_grad_enabled() and the context manager torch.no_grad().
In C++, the flag is exposed through
GradMode::is_enabled()andGradMode::set_enabled()Fixes #3627