Skip to content

Fix BatchNorm double backwards memory leak (v.0.2.0)#2326

Merged
gchanan merged 3 commits intopytorch:v0.2.0from
gchanan:batchnorm_doubleback_memleak_20
Aug 10, 2017
Merged

Fix BatchNorm double backwards memory leak (v.0.2.0)#2326
gchanan merged 3 commits intopytorch:v0.2.0from
gchanan:batchnorm_doubleback_memleak_20

Conversation

@gchanan
Copy link
Contributor

@gchanan gchanan commented Aug 7, 2017

This fixes a couple of issues:

  1. Fixes python reference counts in BatchNormBackwardBackward; previously there were a couple of issues such as using initializing THPObjectPtr with Py_None, when THPVariableWrap already does the correct thing and returns Py_RETURN_NONE.
  2. Fixes the "saved_for" parameter in BatchNorm and Conv. Previously, these were passed as the object itself, rather than the Backwards object, i.e. ConvForward would pass ConvForward as the save for backward, which is wrong (you never save something for the forward). I'm not sure in these specific cases if it were possible to construct a graph where this was a problem (I wasn't able to with non-affine BatchNorm), but it's good to fix this anyway.

gchanan added 2 commits August 7, 2017 15:46
…nction.

Previously, these Functions passed themselves, i.e. the saved_for from
ConvForward would be ConvForward.
@gchanan gchanan merged commit 40de4e9 into pytorch:v0.2.0 Aug 10, 2017
houseroad added a commit to houseroad/pytorch that referenced this pull request Sep 19, 2019
…66d486 (pytorch#26441)

Summary:
Pull Request resolved: pytorch#26441

Previous import was 1316afc9f972f81340faa05763e2898f38bcc3b0

Included changes:
- **[23bb6ea1](onnx/onnx@23bb6ea1)**: Gemm optional bias (pytorch#2330) <James Allingham>
- **[1ac1f219](onnx/onnx@1ac1f219)**: Changes for AIX platform (pytorch#1913) <kavanabhat>
- **[13b026f5](onnx/onnx@13b026f5)**: Updated test cases for reshape (pytorch#2127) <James Allingham>
- **[97fcfe30](onnx/onnx@97fcfe30)**: Replace is by == (pytorch#2326) <G. Ramalingam>
- **[3b5601e6](onnx/onnx@3b5601e6)**: Updated docs for strides and dilations attributes  (pytorch#2291) <James Allingham>
- **[d0c697b1](onnx/onnx@d0c697b1)**: Revamped test cases for Gemm (pytorch#2060) <James Allingham>
- **[a3955c3c](onnx/onnx@a3955c3c)**: Add more shape inference tests for Logical operators to improve coverage (pytorch#2133) <Hariharan Seshadri>
- **[e2e12d97](onnx/onnx@e2e12d97)**: Change incorrect use of ValueError to TypeError (pytorch#2304) <prcvih>
- **[1f4b5f8c](onnx/onnx@1f4b5f8c)**: Support dynamic 'pads' and 'value' in Pad operator (pytorch#2031) <Hariharan Seshadri>

Test Plan: ci

Differential Revision: D17466717

fbshipit-source-id: cf62916a92cf457adcc53c48f40f0d18cd11e034
facebook-github-bot pushed a commit that referenced this pull request Sep 24, 2019
…66d486 (#26441)

Summary:
Pull Request resolved: #26441

Previous import was 1316afc9f972f81340faa05763e2898f38bcc3b0

Included changes:
- **[23bb6ea1](onnx/onnx@23bb6ea1)**: Gemm optional bias (#2330) <James Allingham>
- **[1ac1f219](onnx/onnx@1ac1f219)**: Changes for AIX platform (#1913) <kavanabhat>
- **[13b026f5](onnx/onnx@13b026f5)**: Updated test cases for reshape (#2127) <James Allingham>
- **[97fcfe30](onnx/onnx@97fcfe30)**: Replace is by == (#2326) <G. Ramalingam>
- **[3b5601e6](onnx/onnx@3b5601e6)**: Updated docs for strides and dilations attributes  (#2291) <James Allingham>
- **[d0c697b1](onnx/onnx@d0c697b1)**: Revamped test cases for Gemm (#2060) <James Allingham>
- **[a3955c3c](onnx/onnx@a3955c3c)**: Add more shape inference tests for Logical operators to improve coverage (#2133) <Hariharan Seshadri>
- **[e2e12d97](onnx/onnx@e2e12d97)**: Change incorrect use of ValueError to TypeError (#2304) <prcvih>
- **[1f4b5f8c](onnx/onnx@1f4b5f8c)**: Support dynamic 'pads' and 'value' in Pad operator (#2031) <Hariharan Seshadri>

Test Plan: ci

Reviewed By: hl475

Differential Revision: D17466717

fbshipit-source-id: 0f89a7a5a821d2c693492c99b4bebd5966e21d9f
rraminen pushed a commit to rraminen/pytorch that referenced this pull request Jul 18, 2025
pytorch#2326)

Fixes https://ontrack-internal.amd.com/browse/SWDEV-541809

Upgrading tensorboard after numpy upgrade
Ran in
**registry-sc-harbor.amd.com/framework/compute-rocm-dkms-no-npi-hipclang:16381_ubuntu24.04_py3.12_pytorch_lw_rocm7.0_internal_testing_afe8b782**

```
    7  git checkout rocm7.0_IT_upgrade_tensorboard
    8  pip install .ci/docker/requirements-ci.txt
    9  pip install -r .ci/docker/requirements-ci.txt
   10  PYTORCH_TEST_WITH_ROCM=1 python test/test_monitor.py TestMonitorTensorboard.test_event_handler

root@ubb4-rack-22:/var/lib/jenkins/pytorch# PYTORCH_TEST_WITH_ROCM=1 python test/test_monitor.py TestMonitorTensorboard.test_event_handler
/opt/venv/lib/python3.12/site-packages/google/protobuf/internal/well_known_types.py:91: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
  _EPOCH_DATETIME_NAIVE = datetime.datetime.utcfromtimestamp(0)
.
----------------------------------------------------------------------
Ran 1 test in 0.327s

OK
root@ubb4-rack-22:/var/lib/jenkins/pytorch#

```
leonling-ll pushed a commit to leonling-ll/pytorch that referenced this pull request Jan 23, 2026
pytorch#2326)

Fixes https://ontrack-internal.amd.com/browse/SWDEV-541809

Upgrading tensorboard after numpy upgrade
Ran in
**registry-sc-harbor.amd.com/framework/compute-rocm-dkms-no-npi-hipclang:16381_ubuntu24.04_py3.12_pytorch_lw_rocm7.0_internal_testing_afe8b782**

```
    7  git checkout rocm7.0_IT_upgrade_tensorboard
    8  pip install .ci/docker/requirements-ci.txt
    9  pip install -r .ci/docker/requirements-ci.txt
   10  PYTORCH_TEST_WITH_ROCM=1 python test/test_monitor.py TestMonitorTensorboard.test_event_handler

root@ubb4-rack-22:/var/lib/jenkins/pytorch# PYTORCH_TEST_WITH_ROCM=1 python test/test_monitor.py TestMonitorTensorboard.test_event_handler
/opt/venv/lib/python3.12/site-packages/google/protobuf/internal/well_known_types.py:91: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
  _EPOCH_DATETIME_NAIVE = datetime.datetime.utcfromtimestamp(0)
.
----------------------------------------------------------------------
Ran 1 test in 0.327s

OK
root@ubb4-rack-22:/var/lib/jenkins/pytorch#

```

(cherry picked from commit c7f61f4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant