Skip to content

Commit 62e2609

Browse files
xuzhao9facebook-github-bot
authored andcommitted
Hardcode the numpy version (#2316)
Summary: When there is a big numpy version bump (1.21.2 -> 2.0.0), `pip install` will somehow automatically upgrade numpy version to 2.0.0 even when the old version (1.21.2) has been installed. Therefore, we have to hardcode numpy version both globally and for the models whose install will cause numpy to unexpectedly upgrade. Since downstream CI supports Python 3.8 as the lowest supported Python version, we have to pin numpy version to the lowest version used in the downstream CI. Pull Request resolved: #2316 Reviewed By: aaronenyeshi Differential Revision: D58787422 Pulled By: xuzhao9 fbshipit-source-id: 1fdc667478350d831bdd83d434c3e4c5620b7e71
1 parent 8ab8a3e commit 62e2609

File tree

7 files changed

+32
-12
lines changed

7 files changed

+32
-12
lines changed

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ transformers==4.38.1
1515
MonkeyType
1616
psutil
1717
pyyaml
18-
numpy
18+
# We need to pin numpy version to the same as the torch testing environment
19+
# which still supports python 3.8
20+
numpy==1.21.2; python_version < '3.11'
21+
numpy==1.26.0; python_version >= '3.11'
1922
opencv-python
2023
submitit
2124
pynvml

torchbenchmark/models/Background_Matting/requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
numpy
1+
# We need to pin numpy version to the same as the torch testing environment
2+
# which still supports python 3.8
3+
numpy==1.21.2; python_version < '3.11'
4+
numpy==1.26.0; python_version >= '3.11'
25
opencv-python
36
pandas
47
Pillow
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
numba
1+
numba
2+
# We need to pin numpy version to the same as the torch testing environment
3+
# which still supports python 3.8
4+
numpy==1.21.2; python_version < '3.11'
5+
numpy==1.26.0; python_version >= '3.11'

torchbenchmark/models/tacotron2/requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
numpy
1+
# We need to pin numpy version to the same as the torch testing environment
2+
# which still supports python 3.8
3+
numpy==1.21.2; python_version < '3.11'
4+
numpy==1.26.0; python_version >= '3.11'
25
inflect
36
scipy
47
Unidecode
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
git+https://github.com/facebookresearch/detectron2.git@0df2d73d0013db7de629602c23cc120219b4f2b8
22
omegaconf==2.3.0
3-
numpy
3+
# We need to pin numpy version to the same as the torch testing environment
4+
# which still supports python 3.8
5+
numpy==1.21.2; python_version < '3.11'
6+
numpy==1.26.0; python_version >= '3.11'

utils/build_requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# We need to pin numpy version to the same as the torch testing environment
2+
# which still supports python 3.8
3+
numpy==1.21.2; python_version < '3.11'
4+
numpy==1.26.0; python_version >= '3.11'
5+
psutil
6+
pyyaml

utils/cuda_utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
# defines the default CUDA version to compile against
1111
DEFAULT_CUDA_VERSION = "12.4"
12+
REPO_ROOT = Path(__file__).parent.parent
1213

1314
CUDA_VERSION_MAP = {
1415
"12.4": {
@@ -17,11 +18,9 @@
1718
},
1819
}
1920
PIN_CMAKE_VERSION = "3.22.*"
20-
# the numpy version needs to be consistent with
21-
# https://github.com/pytorch/builder/blob/e66e48f9b1968213c6a7ce3ca8df6621435f0a9c/wheel/build_wheel.sh#L146
22-
PIN_NUMPY_VERSION = "1.23.5"
23-
TORCHBENCH_TORCH_NIGHTLY_PACKAGES = ["torch", "torchvision", "torchaudio"]
2421

22+
TORCHBENCH_TORCH_NIGHTLY_PACKAGES = ["torch", "torchvision", "torchaudio"]
23+
BUILD_REQUIREMENTS_FILE = REPO_ROOT.joinpath("utils", "build_requirements.txt")
2524

2625
def _nvcc_output_match(nvcc_output, target_cuda_version):
2726
regex = "release (.*),"
@@ -153,9 +152,8 @@ def install_torch_build_deps(cuda_version: str):
153152
build_deps = ["ffmpeg"]
154153
cmd = ["conda", "install", "-y"] + build_deps
155154
subprocess.check_call(cmd)
156-
# pip deps
157-
pip_deps = [f"numpy=={PIN_NUMPY_VERSION}"]
158-
cmd = ["pip", "install"] + pip_deps
155+
# pip build deps
156+
cmd = ["pip", "install", "-r"] + str(BUILD_REQUIREMENTS_FILE.resolve())
159157
subprocess.check_call(cmd)
160158
# conda forge deps
161159
# ubuntu 22.04 comes with libstdcxx6 12.3.0

0 commit comments

Comments
 (0)