forked from Kaggle/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.tmpl
708 lines (643 loc) · 27.4 KB
/
Dockerfile.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
ARG BASE_IMAGE_REPO
ARG BASE_IMAGE_TAG
ARG CPU_BASE_IMAGE_NAME
ARG GPU_BASE_IMAGE_NAME
ARG LIGHTGBM_VERSION
ARG TORCH_VERSION
ARG TORCHAUDIO_VERSION
ARG TORCHTEXT_VERSION
ARG TORCHVISION_VERSION
ARG JAX_VERSION
{{ if eq .Accelerator "gpu" }}
FROM gcr.io/kaggle-images/python-lightgbm-whl:${GPU_BASE_IMAGE_NAME}-${BASE_IMAGE_TAG}-${LIGHTGBM_VERSION} AS lightgbm_whl
FROM gcr.io/kaggle-images/python-torch-whl:${GPU_BASE_IMAGE_NAME}-${BASE_IMAGE_TAG}-${TORCH_VERSION} AS torch_whl
FROM gcr.io/kaggle-images/python-jaxlib-whl:${GPU_BASE_IMAGE_NAME}-${BASE_IMAGE_TAG}-${JAX_VERSION} AS jaxlib_whl
FROM ${BASE_IMAGE_REPO}/${GPU_BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}
{{ else }}
FROM ${BASE_IMAGE_REPO}/${CPU_BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}
{{ end }}
# Ensures shared libraries installed with conda can be found by the dynamic link loader.
ENV LIBRARY_PATH="$LIBRARY_PATH:/opt/conda/lib"
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/conda/lib"
{{ if eq .Accelerator "gpu" }}
ARG CUDA_MAJOR_VERSION
ARG CUDA_MINOR_VERSION
ENV CUDA_MAJOR_VERSION=${CUDA_MAJOR_VERSION}
ENV CUDA_MINOR_VERSION=${CUDA_MINOR_VERSION}
# Make sure we are on the right version of CUDA
RUN update-alternatives --set cuda /usr/local/cuda-$CUDA_MAJOR_VERSION.$CUDA_MINOR_VERSION
# NVIDIA binaries from the host are mounted to /opt/bin.
ENV PATH=/opt/bin:${PATH}
# Add CUDA stubs to LD_LIBRARY_PATH to support building the GPU image on a CPU machine.
ENV LD_LIBRARY_PATH_NO_STUBS="$LD_LIBRARY_PATH"
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64/stubs"
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1
{{ end }}
# Keep these variables in sync if base image is updated.
ENV TENSORFLOW_VERSION=2.15.0
# See https://github.com/tensorflow/io#tensorflow-version-compatibility
ENV TENSORFLOW_IO_VERSION=0.35.0
# We need to redefine the ARG here to get the ARG value defined above the FROM instruction.
# See: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG LIGHTGBM_VERSION
ARG TORCH_VERSION
ARG TORCHAUDIO_VERSION
ARG TORCHTEXT_VERSION
ARG TORCHVISION_VERSION
ARG JAX_VERSION
# Disable pesky logs like: KMP_AFFINITY: pid 6121 tid 6121 thread 0 bound to OS proc set 0
# See: https://stackoverflow.com/questions/57385766/disable-tensorflow-log-information
ENV KMP_WARNINGS=0
# Also make the KMP logs noverbose.
# https://stackoverflow.com/questions/70250304/stop-tensorflow-from-printing-warning-message
ENV KMP_SETTINGS=false
# Remove the pip as the root user warning.
ENV PIP_ROOT_USER_ACTION=ignore
ADD clean-layer.sh /tmp/clean-layer.sh
ADD patches/keras_patch.sh /tmp/keras_patch.sh
ADD patches/nbconvert-extensions.tpl /opt/kaggle/nbconvert-extensions.tpl
ADD patches/template_conf.json /opt/kaggle/conf.json
# b/276344496: Install specific version of boto3, because 1.26.103 is broken.
RUN pip install boto3==1.26.100 && \
/tmp/clean-layer.sh
{{ if eq .Accelerator "gpu" }}
# b/200968891 Keeps horovod once torch is upgraded.
RUN pip uninstall -y horovod && \
/tmp/clean-layer.sh
{{ end }}
# Update GPG key per documentation at https://cloud.google.com/compute/docs/troubleshooting/known-issues
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
# Use a fixed apt-get repo to stop intermittent failures due to flaky httpredir connections,
# as described by Lionel Chan at http://stackoverflow.com/a/37426929/5881346
RUN sed -i "s/httpredir.debian.org/debian.uchicago.edu/" /etc/apt/sources.list && \
apt-get update --allow-releaseinfo-change && \
# Needed by lightGBM (GPU build)
# https://lightgbm.readthedocs.io/en/latest/GPU-Tutorial.html#build-lightgbm
apt-get install -y build-essential unzip cmake libboost-dev libboost-system-dev libboost-filesystem-dev p7zip-full && \
# b/182601974: ssh client was removed from the base image but is required for packages such as stable-baselines.
apt-get install -y openssh-client && \
/tmp/clean-layer.sh
# b/128333086: Set PROJ_LIB to points to the proj4 cartographic library.
ENV PROJ_LIB=/opt/conda/share/proj
# Install conda packages not available on pip.
# When using pip in a conda environment, conda commands should be ran first and then
# the remaining pip commands: https://www.anaconda.com/using-pip-in-a-conda-environment/
RUN conda config --add channels nvidia && \
conda config --add channels rapidsai && \
conda config --set solver libmamba && \
# b/299991198 remove curl/libcurl install once DLVM base image includes version >= 7.86
conda install -c conda-forge mamba curl libcurl && \
# Base image channel order: conda-forge (highest priority), defaults.
# End state: rapidsai (highest priority), nvidia, conda-forge, defaults.
mamba install -y mkl cartopy imagemagick pyproj "shapely<2" && \
/tmp/clean-layer.sh
# Install spacy
# b/232247930: uninstall pyarrow to avoid double installation with the GPU specific version.
# b/341938540: unistall grpc-cpp to allow >=v24.4 cudf and cuml to be installed.
{{ if eq .Accelerator "gpu" }}
RUN pip uninstall -y pyarrow && \
mamba remove -y --force grpc-cpp && \
mamba install -y -c conda-forge spacy cudf>=24.4 cuml>=24.4 cupy cuda-version=$CUDA_MAJOR_VERSION.$CUDA_MINOR_VERSION && \
/tmp/clean-layer.sh
{{ else }}
RUN pip install spacy && \
/tmp/clean-layer.sh
{{ end}}
# Install PyTorch
{{ if eq .Accelerator "gpu" }}
COPY --from=torch_whl /tmp/whl/*.whl /tmp/torch/
RUN mamba install -y -c pytorch magma-cuda${CUDA_MAJOR_VERSION}${CUDA_MINOR_VERSION} && \
pip install /tmp/torch/*.whl && \
# b/255757999 openmp (libomp.so) is an dependency of libtorchtext and libtorchaudio but
mamba install -y openmp && \
rm -rf /tmp/torch && \
/tmp/clean-layer.sh
{{ else }}
RUN pip install \
torch==$TORCH_VERSION+cpu \
torchvision==$TORCHVISION_VERSION+cpu \
torchaudio==$TORCHAUDIO_VERSION+cpu \
torchtext==$TORCHTEXT_VERSION \
-f https://download.pytorch.org/whl/torch_stable.html && \
/tmp/clean-layer.sh
{{ end }}
# Install LightGBM
{{ if eq .Accelerator "gpu" }}
COPY --from=lightgbm_whl /tmp/whl/*.whl /tmp/lightgbm/
# Install OpenCL (required by LightGBM GPU version)
RUN apt-get install -y ocl-icd-libopencl1 clinfo && \
mkdir -p /etc/OpenCL/vendors && \
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd && \
pip install /tmp/lightgbm/*.whl && \
rm -rf /tmp/lightgbm && \
/tmp/clean-layer.sh
{{ else }}
RUN pip install lightgbm==$LIGHTGBM_VERSION && \
/tmp/clean-layer.sh
{{ end }}
# Install JAX
{{ if eq .Accelerator "gpu" }}
COPY --from=jaxlib_whl /tmp/whl/*.whl /tmp/jax/
# b/319722433#comment9: Use pip wheels once versions matches our CUDA version.
RUN pip install /tmp/jax/*.whl jax==$JAX_VERSION && \
/tmp/clean-layer.sh
{{ else }}
RUN pip install jax[cpu] && \
/tmp/clean-layer.sh
{{ end }}
# Install GPU specific packages
{{ if eq .Accelerator "gpu" }}
# Install GPU-only packages
# No specific package for nnabla-ext-cuda 12.x minor versions.
RUN export PATH=/usr/local/cuda/bin:$PATH && \
export CUDA_ROOT=/usr/local/cuda && \
pip install pycuda \
pynvrtc \
pynvml && \
/tmp/clean-layer.sh
{{ end }}
# (b/308525631) Pin Matplotlib until seaborn can be upgraded
# to >0.13.0 (now it's stuck by a package conflict with ydata-profiling 4.5.1).
RUN JAXVER=$(pip freeze | grep -e "^jax==") && \
pip install --upgrade \
"matplotlib<3.8.0" \
seaborn \
python-dateutil dask dask-expr igraph \
pyyaml joblib geopy mne pyshp \
pandas \
polars \
flax \
"${JAXVER}" && \
/tmp/clean-layer.sh
RUN apt-get update && \
apt-get install -y default-jre && \
/tmp/clean-layer.sh
RUN pip install -f http://h2o-release.s3.amazonaws.com/h2o/latest_stable_Py.html h2o && /tmp/clean-layer.sh
# b/318672158 Use simply tensorflow-probability once > 0.23.0 is released.
RUN pip install \
"tensorflow==${TENSORFLOW_VERSION}" \
"tensorflow-io==${TENSORFLOW_IO_VERSION}" \
git+https://github.com/tensorflow/probability.git@fbc5ebe9b1d343113fb917010096cfd88b32eecf \
tensorflow_text \
"tensorflow_hub>=0.16.0" \
# b/331799280 remove once other packages over to dm-tre
optree \
tf-keras && \
/tmp/clean-layer.sh
# b/318672158 Use simply tensorflow_decision_forests on next release, expected with tf 2.16
RUN pip install tensorflow_decision_forests==1.8.1 --no-deps && \
/tmp/clean-layer.sh
RUN chmod +x /tmp/keras_patch.sh && \
/tmp/keras_patch.sh
ADD patches/keras_internal.py /opt/conda/lib/python3.10/site-packages/tensorflow_decision_forests/keras/keras_internal.py
ADD patches/keras_internal_test.py /opt/conda/lib/python3.10/site-packages/tensorflow_decision_forests/keras/keras_internal_test.py
# Remove "--no-deps" flag and "namex" package once Keras 3.* is included in our base image.
# We ignore dependencies since tf2.15 and Keras 3.* should work despite pip saying it won't.
# Currently, keras tries to install a nightly version of tf 2.16: https://github.com/keras-team/keras/blob/fe2f54aa5bc42fb23a96449cf90434ab9bb6a2cd/requirements.txt#L2
# b/341360061 Unpin keras-nlp once kaggle-hub is able to provide task.json file when requested
RUN pip install --no-deps "keras>3" keras-cv keras-nlp namex && \
/tmp/clean-layer.sh
# b/328788268 libpysal 4.10 seems to fail with "module 'shapely' has no attribute 'Geometry'. Did you mean: 'geometry'"
RUN pip install pysal "libpysal==4.9.2"
RUN apt-get install -y libfreetype6-dev && \
apt-get install -y libglib2.0-0 libxext6 libsm6 libxrender1 libfontconfig1 --fix-missing && \
pip install gensim \
textblob \
wordcloud \
xgboost \
pydot \
hep_ml && \
# NLTK Project datasets
mkdir -p /usr/share/nltk_data && \
# NLTK Downloader no longer continues smoothly after an error, so we explicitly list
# the corpuses that work
# "yes | ..." answers yes to the retry prompt in case of an error. See b/133762095.
yes | python -m nltk.downloader -d /usr/share/nltk_data abc alpino averaged_perceptron_tagger \
basque_grammars biocreative_ppi bllip_wsj_no_aux \
book_grammars brown brown_tei cess_cat cess_esp chat80 city_database cmudict \
comtrans conll2000 conll2002 conll2007 crubadan dependency_treebank \
europarl_raw floresta gazetteers genesis gutenberg \
ieer inaugural indian jeita kimmo knbc large_grammars lin_thesaurus mac_morpho machado \
masc_tagged maxent_ne_chunker maxent_treebank_pos_tagger moses_sample movie_reviews \
mte_teip5 names nps_chat omw opinion_lexicon paradigms \
pil pl196x porter_test ppattach problem_reports product_reviews_1 product_reviews_2 propbank \
pros_cons ptb punkt qc reuters rslp rte sample_grammars semcor senseval sentence_polarity \
sentiwordnet shakespeare sinica_treebank smultron snowball_data spanish_grammars \
state_union stopwords subjectivity swadesh switchboard tagsets timit toolbox treebank \
twitter_samples udhr2 udhr unicode_samples universal_tagset universal_treebanks_v20 \
vader_lexicon verbnet webtext word2vec_sample wordnet wordnet_ic words ycoe && \
# Stop-words
pip install stop-words \
scikit-image && \
/tmp/clean-layer.sh
RUN pip install opencv-contrib-python opencv-python && \
/tmp/clean-layer.sh
# Pin scipy until we update JAX b/335003097
RUN pip install "scipy==1.12.0" \
# Scikit-learn accelerated library for x86
"scikit-learn-intelex>=2023.0.1" \
# HDF5 support
h5py \
# PUDB, for local debugging convenience
pudb \
imbalanced-learn \
# Profiling and other utilities
line_profiler \
bokeh \
numba \
datashader \
# Boruta (python implementation)
Boruta && \
apt-get install -y graphviz && pip install graphviz && \
# Pandoc is a dependency of deap
apt-get install -y pandoc && \
pip install essentia
RUN apt-get install -y git-lfs && \
/tmp/clean-layer.sh
# vtk with dependencies
RUN apt-get install -y libgl1-mesa-glx && \
pip install vtk && \
# xvfbwrapper with dependencies
apt-get install -y xvfb && \
pip install xvfbwrapper && \
/tmp/clean-layer.sh
RUN rm -rf /opt/conda/lib/python3.10/site-packages/Shapely-1.8.5.post1.dist-info/
RUN pip install mpld3 \
gpxpy \
arrow \
nilearn \
nibabel \
imgaug \
preprocessing \
path.py \
Geohash && \
pip install deap \
# b/302136621 Fix eli5 import for learntools, newer version require scikit-learn > 1.3
"tpot==0.12.1" \
scikit-optimize \
haversine \
toolz cytoolz \
plotly \
hyperopt \
fitter \
langid \
# Useful data exploration libraries (for missing data and generating reports)
missingno \
pandas-profiling \
s2sphere \
bayesian-optimization \
matplotlib-venn \
pyldavis \
mlxtend \
altair \
ImageHash \
ecos \
CVXcanon \
pymc3 \
imagecodecs \
tifffile \
spectral \
descartes \
geojson \
pydicom \
wavio \
SimpleITK \
hmmlearn \
gplearn \
squarify \
fuzzywuzzy \
python-louvain \
pyexcel-ods \
sklearn-pandas \
stemming \
# b/266272046 prophet 1.1.2 breaks the test
prophet==1.1.1 \
# b/283847935 holidays >0.24 is broken
"holidays==0.24" \
holoviews \
geoviews \
hypertools \
mlens \
scikit-multilearn \
cleverhans \
leven \
catboost \
folium \
scikit-plot \
fury dipy \
plotnine \
scikit-surprise \
pymongo \
geoplot \
eli5 \
kaggle \
kagglehub \
google-generativeai \
pytest && \
/tmp/clean-layer.sh
RUN rm -rf /opt/conda/lib/python3.10/site-packages/numpy-1.23.5.dist-info*
# Add google PAIR-code Facets
RUN cd /opt/ && git clone https://github.com/PAIR-code/facets && cd facets/ && jupyter nbextension install facets-dist/ --user && \
export PYTHONPATH=$PYTHONPATH:/opt/facets/facets_overview/python/ && \
pip install kmodes --no-dependencies && \
pip install librosa \
polyglot \
sentencepiece \
cufflinks \
lime \
memory_profiler && \
/tmp/clean-layer.sh
RUN pip install cython \
fasttext && \
apt-get install -y libhunspell-dev && pip install hunspell
RUN pip install annoy \
category_encoders && \
# b/183041606#comment5: the Kaggle data proxy doesn't support these APIs. If the library is missing, it falls back to using a regular BigQuery query to fetch data.
pip uninstall -y google-cloud-bigquery-storage && \
# google-cloud-automl 2.0.0 introduced incompatible API changes, need to pin to 1.0.1
# After launch this should be installed from pip
pip install git+https://github.com/googleapis/python-aiplatform.git@mb-release \
google-cloud-automl==1.0.1 \
google-api-core==1.33.2 \
google-cloud-bigquery \
google-cloud-storage && \
# Split these installations to avoid `pip._vendor.resolvelib.resolvers.ResolutionTooDeep: 200000`
# TODO(b/315753846) Unpin translate package.
pip install google-cloud-translate==3.12.1 \
google-cloud-language==2.* \
google-cloud-videointelligence==2.* \
google-cloud-vision==2.* \
protobuf==3.20.3 \
ortools \
scattertext \
# Pandas data reader
pandas-datareader \
wordsegment \
emoji \
# Add Japanese morphological analysis engine
janome \
wfdb \
vecstack \
# yellowbrick machine learning visualization library
yellowbrick \
mlcrate && \
/tmp/clean-layer.sh
# b/273059949 The pre-installed nbconvert is slow on html conversions and has to be force-uninstalled.
# b/274619697 learntools also requires a specific nbconvert right now
RUN rm -rf /opt/conda/lib/python3.10/site-packages/{nbconvert,nbclient,mistune,platformdirs}*
# Fix qgrid by pinning ipywidgets https://github.com/quantopian/qgrid/issues/376
# allennlp \
RUN pip install bleach \
certifi \
cycler \
decorator \
entrypoints \
html5lib \
ipykernel \
ipython \
ipython-genutils \
ipywidgets==7.7.1 \
isoweek \
jedi \
jsonschema \
jupyter-client \
jupyter-console \
jupyter-core \
jupyterlab-lsp \
MarkupSafe \
mistune \
nbformat \
notebook \
"nbconvert==6.4.5" \
papermill \
python-lsp-server[all] \
olefile \
kornia \
pandas_summary \
pandocfilters \
pexpect \
pickleshare \
# TODO(b/290035631) unpin when EasyOCR did a release.
Pillow==9.5.0 && \
# Install openslide and its python binding
apt-get install -y openslide-tools && \
pip install openslide-python \
ptyprocess \
Pygments \
pyparsing \
pytz \
PyYAML \
pyzmq \
qtconsole \
six \
terminado \
tornado \
tqdm \
traitlets \
wcwidth \
webencodings \
widgetsnbextension \
# Require pyarrow newer than https://github.com/advisories/GHSA-5wvp-7f3h-6wmm
{{ if eq .Accelerator "gpu" }} pyarrow {{ else }} "pyarrow>=14.0.1" {{ end }} \
feather-format \
fastai
RUN python -m spacy download en_core_web_sm && python -m spacy download en_core_web_lg && \
apt-get update && apt-get install -y ffmpeg && \
/tmp/clean-layer.sh
###########
#
# NEW CONTRIBUTORS:
# Please add new pip/apt installs in this block. Don't forget a "&& \" at the end
# of all non-final lines. Thanks!
#
###########
RUN rm /opt/conda/lib/python3.10/site-packages/google*/direct_url.json
RUN rm /opt/conda/lib/python3.10/site-packages/google*/REQUESTED
# dlib has a libmkl incompatibility:
# test_dlib_face_detector (test_dlib.TestDLib) ... INTEL MKL ERROR: /opt/conda/bin/../lib/libmkl_avx512.so.2: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8.
# Intel MKL FATAL ERROR: Cannot load libmkl_avx512.so.2 or libmkl_def.so.2.
# nnabla breaks protobuf compatibiilty:
RUN pip install flashtext \
wandb \
# b/214080882 blake3 0.3.0 is not compatible with vaex.
blake3==0.2.1 \
vaex \
pyemd \
pyupset \
pympler \
featuretools \
#-e git+https://github.com/SohierDane/BigQuery_Helper#egg=bq_helper \
git+https://github.com/Kaggle/learntools \
ray \
gym \
pyarabic \
pandasql \
# b/302136621 Fix eli5 import for learntools
scikit-learn==1.2.2 \
hpsklearn \
kmapper \
# b/329869023 shap 0.45.0 breaks learntools
shap==0.44.1 \
cesium \
rgf_python \
jieba \
# ggplot is broken and main repo does not merge and release https://github.com/yhat/ggpy/pull/668
https://github.com/hbasria/ggpy/archive/0.11.5.zip \
tsfresh \
pykalman \
optuna \
plotly_express \
albumentations \
accelerate \
# b/290207097 switch back to the pip catalyst package when bug fixed
# https://github.com/catalyst-team/catalyst/issues/1440
git+https://github.com/Philmod/catalyst.git@fix-fp16#egg=catalyst \
osmnx && \
apt-get -y install libspatialindex-dev
RUN pip install pytorch-ignite \
qgrid \
bqplot \
earthengine-api \
transformers \
datasets \
s3fs \
gcsfs \
kaggle-environments \
geopandas \
"shapely<2" \
vowpalwabbit \
pydub \
pydegensac \
torchmetrics \
pytorch-lightning \
sympy \
# flask is used by agents in the simulation competitions.
flask \
# pycrypto is used by competitions team.
pycryptodome \
easyocr \
# ipympl adds interactive widget support for matplotlib
ipympl==0.7.0 \
onnx \
tables \
openpyxl \
timm \
torchinfo && \
pip install git+https://github.com/facebookresearch/segment-anything.git && \
# b/343971718: remove duplicate aiohttp installs, and reinstall it
rm -rf /opt/conda/lib/python3.10/site-packages/aiohttp* && \
mamba install --force-reinstall -y aiohttp && \
/tmp/clean-layer.sh
# Download base easyocr models.
# https://github.com/JaidedAI/EasyOCR#usage
RUN mkdir -p /root/.EasyOCR/model && \
wget --no-verbose "https://github.com/JaidedAI/EasyOCR/releases/download/v1.3/latin_g2.zip" -O /root/.EasyOCR/model/latin.zip && \
unzip /root/.EasyOCR/model/latin.zip -d /root/.EasyOCR/model/ && \
rm /root/.EasyOCR/model/latin.zip && \
wget --no-verbose "https://github.com/JaidedAI/EasyOCR/releases/download/v1.3/english_g2.zip" -O /root/.EasyOCR/model/english.zip && \
unzip /root/.EasyOCR/model/english.zip -d /root/.EasyOCR/model/ && \
rm /root/.EasyOCR/model/english.zip && \
wget --no-verbose "https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/craft_mlt_25k.zip" -O /root/.EasyOCR/model/craft_mlt_25k.zip && \
unzip /root/.EasyOCR/model/craft_mlt_25k.zip -d /root/.EasyOCR/model/ && \
rm /root/.EasyOCR/model/craft_mlt_25k.zip && \
/tmp/clean-layer.sh
# Tesseract and some associated utility packages
RUN apt-get install tesseract-ocr -y && \
pip install pytesseract \
wand \
pdf2image \
PyPDF && \
/tmp/clean-layer.sh
ENV TESSERACT_PATH=/usr/bin/tesseract
# For Facets
ENV PYTHONPATH=$PYTHONPATH:/opt/facets/facets_overview/python/
# For Theano with MKL
ENV MKL_THREADING_LAYER=GNU
# Temporary fixes and patches
# Temporary patch for Dask getting downgraded, which breaks Keras
RUN pip install --upgrade dask && \
# Stop jupyter nbconvert trying to rewrite its folder hierarchy
mkdir -p /root/.jupyter && touch /root/.jupyter/jupyter_nbconvert_config.py && touch /root/.jupyter/migrated && \
mkdir -p /.jupyter && touch /.jupyter/jupyter_nbconvert_config.py && touch /.jupyter/migrated && \
# Stop Matplotlib printing junk to the console on first load
sed -i "s/^.*Matplotlib is building the font cache using fc-list.*$/# Warning removed by Kaggle/g" /opt/conda/lib/python3.10/site-packages/matplotlib/font_manager.py && \
# Make matplotlib output in Jupyter notebooks display correctly
mkdir -p /etc/ipython/ && echo "c = get_config(); c.IPKernelApp.matplotlib = 'inline'" > /etc/ipython/ipython_config.py && \
# Temporary patch for broken libpixman 0.38 in conda-forge, symlink to system libpixman 0.34 untile conda package gets updated to 0.38.5 or higher.
ln -sf /usr/lib/x86_64-linux-gnu/libpixman-1.so.0.34.0 /opt/conda/lib/libpixman-1.so.0.38.0 && \
# pin jupyter-server to version 2.12.5; later versions break LSP (b/333854354)
pip install --force-reinstall --no-deps jupyter_server==2.12.5 && \
/tmp/clean-layer.sh
# Fix to import bq_helper library without downgrading setuptools
RUN mkdir -p ~/src && git clone https://github.com/SohierDane/BigQuery_Helper ~/src/BigQuery_Helper && \
mkdir -p ~/src/BigQuery_Helper/bq_helper && \
mv ~/src/BigQuery_Helper/bq_helper.py ~/src/BigQuery_Helper/bq_helper/__init__.py && \
mv ~/src/BigQuery_Helper/test_helper.py ~/src/BigQuery_Helper/bq_helper/ && \
sed -i 's/)/packages=["bq_helper"])/g' ~/src/BigQuery_Helper/setup.py && \
pip install -e ~/src/BigQuery_Helper && \
/tmp/clean-layer.sh
# Add BigQuery client proxy settings
ENV PYTHONUSERBASE "/root/.local"
ADD patches/kaggle_gcp.py /root/.local/lib/python3.10/site-packages/kaggle_gcp.py
ADD patches/kaggle_secrets.py /root/.local/lib/python3.10/site-packages/kaggle_secrets.py
ADD patches/kaggle_session.py /root/.local/lib/python3.10/site-packages/kaggle_session.py
ADD patches/kaggle_web_client.py /root/.local/lib/python3.10/site-packages/kaggle_web_client.py
ADD patches/kaggle_datasets.py /root/.local/lib/python3.10/site-packages/kaggle_datasets.py
ADD patches/log.py /root/.local/lib/python3.10/site-packages/log.py
ADD patches/sitecustomize.py /root/.local/lib/python3.10/site-packages/sitecustomize.py
# Override default imagemagick policies
ADD patches/imagemagick-policy.xml /etc/ImageMagick-6/policy.xml
# Add Kaggle module resolver
ADD patches/kaggle_module_resolver.py /opt/conda/lib/python3.10/site-packages/tensorflow_hub/kaggle_module_resolver.py
RUN sed -i '/from tensorflow_hub import uncompressed_module_resolver/a from tensorflow_hub import kaggle_module_resolver' /opt/conda/lib/python3.10/site-packages/tensorflow_hub/config.py && \
sed -i '/_install_default_resolvers()/a \ \ registry.resolver.add_implementation(kaggle_module_resolver.KaggleFileResolver())' /opt/conda/lib/python3.10/site-packages/tensorflow_hub/config.py
# TensorBoard Jupyter extension. Should be replaced with TensorBoard's provided magic once we have
# worker tunneling support in place.
# b/139212522 re-enable TensorBoard once solution for slowdown is implemented.
# ENV JUPYTER_CONFIG_DIR "/root/.jupyter/"
# RUN pip install jupyter_tensorboard && \
# jupyter serverextension enable jupyter_tensorboard && \
# jupyter tensorboard enable
# ADD patches/tensorboard/notebook.py /opt/conda/lib/python3.10/site-packages/tensorboard/notebook.py
# Disable unnecessary jupyter extensions
#RUN jupyter-nbextension disable nb_conda --py --sys-prefix && \
# jupyter-serverextension disable nb_conda --py --sys-prefix && \
# python -m nb_conda_kernels.install --disable
# Disable preloaded jupyter modules (they add to startup, and break when they are missing)
RUN sed -i /bq_stats/d /etc/ipython/ipython_kernel_config.py && \
sed -i /beatrix/d /etc/ipython/ipython_kernel_config.py && \
sed -i /bigquery/d /etc/ipython/ipython_kernel_config.py && \
sed -i /sql/d /etc/ipython/ipython_kernel_config.py
# Force only one libcusolver
{{ if eq .Accelerator "gpu" }}
RUN rm /opt/conda/bin/../lib/libcusolver.so.11 && ln -s /usr/local/cuda/lib64/libcusolver.so.11 /opt/conda/bin/../lib/libcusolver.so.11
{{ else }}
RUN ln -s /usr/local/cuda/lib64/libcusolver.so.11 /opt/conda/bin/../lib/libcusolver.so.11
{{ end }}
# b/270147159 conda ships with a version of libtinfo which is missing version info causing warnings, replace it with a good version.
RUN rm /opt/conda/lib/libtinfo.so.6 && ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /opt/conda/lib/libtinfo.so.6
# b/276358430 fix Jupyter lsp freezing up the jupyter server
RUN pip install "jupyter-lsp==1.5.1"
# Set backend for matplotlib
ENV MPLBACKEND "agg"
# Set LC_ALL
# https://github.com/explosion/spaCy/issues/12872#issuecomment-1661847588
ENV LC_ALL "POSIX"
ARG GIT_COMMIT=unknown
ARG BUILD_DATE=unknown
LABEL git-commit=$GIT_COMMIT
LABEL build-date=$BUILD_DATE
ENV GIT_COMMIT=${GIT_COMMIT}
ENV BUILD_DATE=${BUILD_DATE}
LABEL tensorflow-version=$TENSORFLOW_VERSION
# Used in the Jenkins `Docker GPU Build` step to restrict the images being pruned.
LABEL kaggle-lang=python
# Correlate current release with the git hash inside the kernel editor by running `!cat /etc/git_commit`.
RUN echo "$GIT_COMMIT" > /etc/git_commit && echo "$BUILD_DATE" > /etc/build_date
{{ if eq .Accelerator "gpu" }}
# Remove the CUDA stubs.
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH_NO_STUBS"
# Add the CUDA home.
ENV CUDA_HOME=/usr/local/cuda
{{ end }}