Skip to content

Commit 4e22769

Browse files
authored
Fix build due to numpy (#1430)
numpy 2.0 and greater is causing issues with handful of packages
1 parent d6f04b1 commit 4e22769

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

Dockerfile.tmpl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ ADD patches/keras_internal.py \
210210
# b/350573866: xgboost v2.1.0 breaks learntools
211211
RUN apt-get install -y libfreetype6-dev && \
212212
apt-get install -y libglib2.0-0 libxext6 libsm6 libxrender1 libfontconfig1 --fix-missing && \
213+
rm -rf /opt/conda/lib/python3.10/site-packages/numpy* && \
214+
pip install "numpy==1.26.4" && \
213215
pip install gensim \
214216
textblob \
215217
wordcloud \
@@ -425,8 +427,7 @@ RUN pip install bleach \
425427
webencodings \
426428
widgetsnbextension \
427429
# Require pyarrow newer than https://github.com/advisories/GHSA-5wvp-7f3h-6wmm
428-
{{ if eq .Accelerator "gpu" }} pyarrow {{ else }} "pyarrow>=14.0.1" {{ end }} \
429-
fastai
430+
{{ if eq .Accelerator "gpu" }} pyarrow {{ else }} "pyarrow>=14.0.1" {{ end }}
430431

431432
RUN python -m spacy download en_core_web_sm && python -m spacy download en_core_web_lg && \
432433
apt-get update && apt-get install -y ffmpeg && \
@@ -470,7 +471,8 @@ RUN pip install wandb \
470471
Rtree \
471472
accelerate && \
472473
apt-get -y install libspatialindex-dev && \
473-
rm -rf /opt/conda/lib/python3.10/site-packages/numpy* && \
474+
# b/370860329: newer versions are not capable with current tensorflow
475+
rm -rf /opt/conda/lib/python3.10/site-packages/numpy* && \
474476
pip install "numpy==1.26.4" && \
475477
pip install pytorch-ignite \
476478
qgrid \
@@ -501,6 +503,8 @@ RUN pip install wandb \
501503
timm \
502504
torchinfo && \
503505
pip install git+https://github.com/facebookresearch/segment-anything.git && \
506+
# b/370860329: newer versions are not capable with current tensorflow
507+
pip install --no-dependencies fastai fastdownload && \
504508
# b/343971718: remove duplicate aiohttp installs, and reinstall it
505509
rm -rf /opt/conda/lib/python3.10/site-packages/aiohttp* && \
506510
mamba install --force-reinstall -y aiohttp && \

tests/test_fastai.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
from fastai.tabular.all import *
66

77
class TestFastAI(unittest.TestCase):
8+
# Basic import
9+
def test_basic(self):
10+
import fastai
11+
import fastcore
12+
import fastprogress
13+
import fastdownload
14+
815
def test_has_version(self):
916
self.assertGreater(len(fastai.__version__), 2)
1017

tests/test_numpy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import unittest
22

3+
from distutils.version import StrictVersion
4+
35
import numpy as np
46
from numpy.distutils.system_info import get_info
57

6-
class TestNumpy(unittest.TestCase):
8+
class TestNumpy(unittest.TestCase):
9+
def test_version(self):
10+
# b/370860329: newer versions are not capable with current tensorflow
11+
self.assertEqual(StrictVersion(np.__version__), StrictVersion("1.26.4"))
12+
713
def test_array(self):
814
array = np.array([1, 3])
915

0 commit comments

Comments
 (0)