Skip to content

Commit ab70550

Browse files
ppwwyyxxfacebook-github-bot
authored andcommitted
drop pytorch1.5 support
Summary: pytorch 1.8 is coming Reviewed By: theschnitz Differential Revision: D25129974 fbshipit-source-id: d461766def65e3bd8f510fdfe469a575e102fb28
1 parent 29cc517 commit ab70550

File tree

18 files changed

+21
-86
lines changed

18 files changed

+21
-86
lines changed

.circleci/config.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ workflows:
217217
torchvision_version: '0.8.1+cpu'
218218
context:
219219
- DOCKERHUB_TOKEN
220-
- linux_gpu_tests:
221-
name: linux_gpu_tests_pytorch1.5
222-
pytorch_version: '1.5+cu101'
223-
torchvision_version: '0.6+cu101'
224220
- linux_gpu_tests:
225221
name: linux_gpu_tests_pytorch1.6
226222
pytorch_version: '1.6+cu101'

.github/workflows/workflow.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ jobs:
3636
strategy:
3737
fail-fast: false
3838
matrix:
39-
torch: [1.5, 1.6, 1.7]
39+
torch: [1.6, 1.7]
4040
include:
41-
- torch: 1.5
42-
torchvision: 0.6
4341
- torch: 1.6
4442
torchvision: 0.7
4543
- torch: 1.7

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Requirements
44
- Linux or macOS with Python ≥ 3.6
5-
- PyTorch ≥ 1.5 and [torchvision](https://github.com/pytorch/vision/) that matches the PyTorch installation.
5+
- PyTorch ≥ 1.6 and [torchvision](https://github.com/pytorch/vision/) that matches the PyTorch installation.
66
Install them together at [pytorch.org](https://pytorch.org) to make sure of this
77
- OpenCV is optional but needed by demo and visualization
88

detectron2/checkpoint/detection_checkpoint.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,7 @@ def __init__(self, model, save_dir="", *, save_to_disk=None, **checkpointables):
2222
save_to_disk=is_main_process if save_to_disk is None else save_to_disk,
2323
**checkpointables,
2424
)
25-
if hasattr(self, "path_manager"):
26-
self.path_manager = PathManager
27-
else:
28-
# This could only happen for open source
29-
# TODO remove after upgrading fvcore version
30-
from iopath.common.file_io import g_pathmgr
31-
32-
for handler in PathManager._path_handlers.values():
33-
try:
34-
g_pathmgr.register_handler(handler)
35-
except KeyError:
36-
pass
25+
self.path_manager = PathManager
3726

3827
def _load_file(self, filename):
3928
if filename.endswith(".pkl"):

detectron2/layers/wrappers.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import torch
1313
from torch.nn import functional as F
1414

15-
from detectron2.utils.env import TORCH_VERSION
16-
1715

1816
def cat(tensors: List[torch.Tensor], dim: int = 0):
1917
"""
@@ -96,33 +94,7 @@ def forward(self, x):
9694
ConvTranspose2d = torch.nn.ConvTranspose2d
9795
BatchNorm2d = torch.nn.BatchNorm2d
9896
interpolate = F.interpolate
99-
100-
101-
if TORCH_VERSION > (1, 5):
102-
Linear = torch.nn.Linear
103-
else:
104-
105-
class Linear(torch.nn.Linear):
106-
"""
107-
A wrapper around :class:`torch.nn.Linear` to support empty inputs and more features.
108-
Because of https://github.com/pytorch/pytorch/issues/34202
109-
"""
110-
111-
def forward(self, x):
112-
if x.numel() == 0:
113-
output_shape = [x.shape[0], self.weight.shape[0]]
114-
115-
empty = _NewEmptyTensorOp.apply(x, output_shape)
116-
if self.training:
117-
# This is to make DDP happy.
118-
# DDP expects all workers to have gradient w.r.t the same set of parameters.
119-
_dummy = sum(x.view(-1)[0] for x in self.parameters()) * 0.0
120-
return empty + _dummy
121-
else:
122-
return empty
123-
124-
x = super().forward(x)
125-
return x
97+
Linear = torch.nn.Linear
12698

12799

128100
def nonzero_tuple(x):

detectron2/modeling/roi_heads/box_head.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from torch import nn
77

88
from detectron2.config import configurable
9-
from detectron2.layers import Conv2d, Linear, ShapeSpec, get_norm
9+
from detectron2.layers import Conv2d, ShapeSpec, get_norm
1010
from detectron2.utils.registry import Registry
1111

1212
__all__ = ["FastRCNNConvFCHead", "build_box_head", "ROI_BOX_HEAD_REGISTRY"]
@@ -67,7 +67,7 @@ def __init__(
6767
for k, fc_dim in enumerate(fc_dims):
6868
if k == 0:
6969
self.add_module("flatten", nn.Flatten())
70-
fc = Linear(int(np.prod(self._output_size)), fc_dim)
70+
fc = nn.Linear(int(np.prod(self._output_size)), fc_dim)
7171
self.add_module("fc{}".format(k + 1), fc)
7272
self.add_module("fc_relu{}".format(k + 1), nn.ReLU())
7373
self.fcs.append(fc)

detectron2/modeling/roi_heads/fast_rcnn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from torch.nn import functional as F
88

99
from detectron2.config import configurable
10-
from detectron2.layers import Linear, ShapeSpec, batched_nms, cat, cross_entropy, nonzero_tuple
10+
from detectron2.layers import ShapeSpec, batched_nms, cat, cross_entropy, nonzero_tuple
1111
from detectron2.modeling.box_regression import Box2BoxTransform
1212
from detectron2.structures import Boxes, Instances
1313
from detectron2.utils.events import get_event_storage
@@ -375,10 +375,10 @@ def __init__(
375375
self.num_classes = num_classes
376376
input_size = input_shape.channels * (input_shape.width or 1) * (input_shape.height or 1)
377377
# prediction layer for num_classes foreground classes and one background class (hence + 1)
378-
self.cls_score = Linear(input_size, num_classes + 1)
378+
self.cls_score = nn.Linear(input_size, num_classes + 1)
379379
num_bbox_reg_classes = 1 if cls_agnostic_bbox_reg else num_classes
380380
box_dim = len(box2box_transform.weights)
381-
self.bbox_pred = Linear(input_size, num_bbox_reg_classes * box_dim)
381+
self.bbox_pred = nn.Linear(input_size, num_bbox_reg_classes * box_dim)
382382

383383
nn.init.normal_(self.cls_score.weight, std=0.01)
384384
nn.init.normal_(self.bbox_pred.weight, std=0.001)

dev/packaging/build_all_wheels.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,4 @@ else
5656
build_one cu101 1.6
5757
build_one cu92 1.6
5858
build_one cpu 1.6
59-
60-
build_one cu102 1.5
61-
build_one cu101 1.5
62-
build_one cu92 1.5
63-
build_one cpu 1.5
6459
fi

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def resolve_any_xref(self, env, fromdocname, builder, target, node, contnode):
7777
"torchvision", "torchvision.ops",
7878
]:
7979
sys.modules[m] = mock.Mock(name=m)
80-
sys.modules['torch'].__version__ = "1.5" # fake version
80+
sys.modules['torch'].__version__ = "1.7" # fake version
8181
else:
8282
try:
8383
torch.ops.detectron2 = mock.Mock(name="torch.ops.detectron2")

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ future
1616
requests
1717
six
1818
git+git://github.com/facebookresearch/fvcore.git
19-
https://download.pytorch.org/whl/cpu/torch-1.5.0%2Bcpu-cp37-cp37m-linux_x86_64.whl
20-
https://download.pytorch.org/whl/cpu/torchvision-0.6.0%2Bcpu-cp37-cp37m-linux_x86_64.whl
19+
https://download.pytorch.org/whl/cpu/torch-1.7.0%2Bcpu-cp37-cp37m-linux_x86_64.whl
20+
https://download.pytorch.org/whl/cpu/torchvision-0.8.1%2Bcpu-cp37-cp37m-linux_x86_64.whl

0 commit comments

Comments
 (0)