Skip to content

Commit 93b635d

Browse files
bandish-shahBandish Shah
authored andcommitted
Explicitly pin PyTorch versions (mosaicml#1688)
* Bound torch to < 1.13 * Updated Docker flow to pin torchtext version
1 parent b1d3172 commit 93b635d

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

docker/Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ ARG PYTORCH_VERSION=1.11.0
2525
# version that corresponds to the PyTorch version
2626
ARG TORCHVISION_VERSION=0.12.0
2727

28+
# The Torchtext version to install.
29+
# Reference https://github.com/pytorch/text#installation to determine the Torchtext
30+
# version that corresponds to the PyTorch version
31+
ARG TORCHTEXT_VERSION=0.12.0
32+
2833
# In the Dockerimage, Pillow-SIMD is installed instead of Pillow. To trick pip into thinking that
2934
# Pillow is also installed (so it won't override it with a future pip install), a Pillow stub is included
3035
# PILLOW_PSEUDOVERSION is the Pillow version that pip thinks is installed
@@ -174,11 +179,16 @@ RUN pip${PYTHON_VERSION} install --no-cache-dir --upgrade /tmp/pillow_stub && \
174179
#################
175180
ARG PYTORCH_VERSION
176181
ARG TORCHVISION_VERSION
182+
ARG TORCHTEXT_VERSION
183+
184+
# Set so supporting PyTorch packages such as Torchvision, Torchaudio, Torchtext pin PyTorch version
185+
ENV PYTORCH_VERSION=${PYTORCH_VERSION}
177186

178187
RUN CUDA_VERSION_TAG=$(python${PYTHON_VERSION} -c "print('cu' + ''.join('${CUDA_VERSION}'.split('.')[:2]) if '${CUDA_VERSION}' else 'cpu')") && \
179188
pip${PYTHON_VERSION} install --no-cache-dir --find-links https://download.pytorch.org/whl/torch_stable.html \
180189
torch==${PYTORCH_VERSION}+${CUDA_VERSION_TAG} \
181-
torchvision==${TORCHVISION_VERSION}+${CUDA_VERSION_TAG}
190+
torchvision==${TORCHVISION_VERSION}+${CUDA_VERSION_TAG} \
191+
torchtext==${TORCHTEXT_VERSION}
182192

183193
###################################
184194
# Mellanox OFED driver installation

docker/build_matrix.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
TAGS:
77
- mosaicml/pytorch:1.10.2_cu113-python3.7-ubuntu20.04
88
TARGET: pytorch_stage
9+
TORCHTEXT_VERSION: 0.11.2
910
TORCHVISION_VERSION: 0.11.3
1011
- BASE_IMAGE: ubuntu:20.04
1112
CUDA_VERSION: ''
@@ -15,6 +16,7 @@
1516
TAGS:
1617
- mosaicml/pytorch:1.10.2_cpu-python3.7-ubuntu20.04
1718
TARGET: pytorch_stage
19+
TORCHTEXT_VERSION: 0.11.2
1820
TORCHVISION_VERSION: 0.11.3
1921
- BASE_IMAGE: nvidia/cuda:11.5.2-cudnn8-devel-ubuntu20.04
2022
CUDA_VERSION: 11.5.2
@@ -23,6 +25,7 @@
2325
TAGS:
2426
- mosaicml/pytorch:1.11.0_cu115-python3.8-ubuntu20.04
2527
TARGET: pytorch_stage
28+
TORCHTEXT_VERSION: 0.12.0
2629
TORCHVISION_VERSION: 0.12.0
2730
- BASE_IMAGE: ubuntu:20.04
2831
CUDA_VERSION: ''
@@ -32,6 +35,7 @@
3235
TAGS:
3336
- mosaicml/pytorch:1.11.0_cpu-python3.8-ubuntu20.04
3437
TARGET: pytorch_stage
38+
TORCHTEXT_VERSION: 0.12.0
3539
TORCHVISION_VERSION: 0.12.0
3640
- BASE_IMAGE: nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04
3741
CUDA_VERSION: 11.6.2
@@ -41,6 +45,7 @@
4145
- mosaicml/pytorch:1.12.1_cu116-python3.9-ubuntu20.04
4246
- mosaicml/pytorch:latest
4347
TARGET: pytorch_stage
48+
TORCHTEXT_VERSION: 0.13.1
4449
TORCHVISION_VERSION: 0.13.1
4550
- BASE_IMAGE: nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04
4651
CUDA_VERSION: 11.6.2
@@ -50,6 +55,7 @@
5055
- mosaicml/pytorch_vision:1.12.1_cu116-python3.9-ubuntu20.04
5156
- mosaicml/pytorch_vision:latest
5257
TARGET: vision_stage
58+
TORCHTEXT_VERSION: 0.13.1
5359
TORCHVISION_VERSION: 0.13.1
5460
- BASE_IMAGE: ubuntu:20.04
5561
CUDA_VERSION: ''
@@ -60,6 +66,7 @@
6066
- mosaicml/pytorch:1.12.1_cpu-python3.9-ubuntu20.04
6167
- mosaicml/pytorch:latest_cpu
6268
TARGET: pytorch_stage
69+
TORCHTEXT_VERSION: 0.13.1
6370
TORCHVISION_VERSION: 0.13.1
6471
- BASE_IMAGE: ubuntu:20.04
6572
CUDA_VERSION: ''
@@ -70,6 +77,7 @@
7077
- mosaicml/pytorch_vision:1.12.1_cpu-python3.9-ubuntu20.04
7178
- mosaicml/pytorch_vision:latest_cpu
7279
TARGET: vision_stage
80+
TORCHTEXT_VERSION: 0.13.1
7381
TORCHVISION_VERSION: 0.13.1
7482
- BASE_IMAGE: nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04
7583
COMPOSER_INSTALL_COMMAND: mosaicml[all]
@@ -79,6 +87,7 @@
7987
TAGS:
8088
- mosaicml/composer:latest
8189
TARGET: composer_stage
90+
TORCHTEXT_VERSION: 0.13.1
8291
TORCHVISION_VERSION: 0.13.1
8392
- BASE_IMAGE: ubuntu:20.04
8493
COMPOSER_INSTALL_COMMAND: mosaicml[all]
@@ -88,6 +97,7 @@
8897
TAGS:
8998
- mosaicml/composer:latest_cpu
9099
TARGET: composer_stage
100+
TORCHTEXT_VERSION: 0.13.1
91101
TORCHVISION_VERSION: 0.13.1
92102
- BASE_IMAGE: nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04
93103
COMPOSER_INSTALL_COMMAND: mosaicml[all]==0.11.0
@@ -97,6 +107,7 @@
97107
TAGS:
98108
- mosaicml/composer:0.11.0
99109
TARGET: composer_stage
110+
TORCHTEXT_VERSION: 0.13.1
100111
TORCHVISION_VERSION: 0.13.1
101112
- BASE_IMAGE: ubuntu:20.04
102113
COMPOSER_INSTALL_COMMAND: mosaicml[all]==0.11.0
@@ -106,6 +117,7 @@
106117
TAGS:
107118
- mosaicml/composer:0.11.0_cpu
108119
TARGET: composer_stage
120+
TORCHTEXT_VERSION: 0.13.1
109121
TORCHVISION_VERSION: 0.13.1
110122
- BASE_IMAGE: nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04
111123
COMPOSER_INSTALL_COMMAND: mosaicml[all]GIT_COMMIT
@@ -114,6 +126,7 @@
114126
PYTORCH_VERSION: 1.12.1
115127
TAGS: []
116128
TARGET: composer_stage
129+
TORCHTEXT_VERSION: 0.13.1
117130
TORCHVISION_VERSION: 0.13.1
118131
- BASE_IMAGE: ubuntu:20.04
119132
COMPOSER_INSTALL_COMMAND: mosaicml[all]GIT_COMMIT
@@ -122,4 +135,5 @@
122135
PYTORCH_VERSION: 1.12.1
123136
TAGS: []
124137
TARGET: composer_stage
138+
TORCHTEXT_VERSION: 0.13.1
125139
TORCHVISION_VERSION: 0.13.1

docker/generate_build_matrix.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ def _get_torchvision_version(pytorch_version: str):
3939
raise ValueError(f'Invalid pytorch_version: {pytorch_version}')
4040

4141

42+
def _get_torchtext_version(pytorch_version: str):
43+
if pytorch_version == '1.12.1':
44+
return '0.13.1'
45+
if pytorch_version == '1.11.0':
46+
return '0.12.0'
47+
if pytorch_version == '1.10.2':
48+
return '0.11.2'
49+
raise ValueError(f'Invalid pytorch_version: {pytorch_version}')
50+
51+
4252
def _get_base_image(cuda_version: str):
4353
if not cuda_version:
4454
return 'ubuntu:20.04'
@@ -136,6 +146,8 @@ def _main():
136146
stage,
137147
'TORCHVISION_VERSION':
138148
_get_torchvision_version(pytorch_version),
149+
'TORCHTEXT_VERSION':
150+
_get_torchtext_version(pytorch_version),
139151
'TAGS':
140152
_get_pytorch_tags(
141153
python_version=python_version,
@@ -175,6 +187,7 @@ def _main():
175187
'PYTORCH_VERSION': pytorch_version,
176188
'TARGET': 'composer_stage',
177189
'TORCHVISION_VERSION': _get_torchvision_version(pytorch_version),
190+
'TORCHTEXT_VERSION': _get_torchtext_version(pytorch_version),
178191
'COMPOSER_INSTALL_COMMAND': f'mosaicml[all]{composer_version}',
179192
'TAGS': _get_composer_tags(
180193
composer_version=composer_version,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def package_files(prefix: str, directory: str, extension: str):
7878
'torchmetrics>=0.7.0,<0.10.0',
7979
'torch_optimizer>=0.3.0,<0.4',
8080
'torchvision>=0.10.0', # torchvision has strict pytorch requirements
81-
'torch>=1.10,<2',
81+
'torch>=1.10,<1.13',
8282
'yahp>=0.1.3,<0.2',
8383
'requests>=2.26.0,<3',
8484
'numpy>=1.21.5,<1.23.0',

0 commit comments

Comments
 (0)