Skip to content

Commit 0044c80

Browse files
authored
Upgrade tensorflow to 2.11 and fix broken build (#204)
http://b/306150775
1 parent 2a42e76 commit 0044c80

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

Dockerfile

+19-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@ ARG BASE_TAG=latest
22

33
FROM gcr.io/kaggle-images/rcran:${BASE_TAG}
44

5+
ARG PYTHON_VERSION=3.10
6+
57
ADD clean-layer.sh /tmp/clean-layer.sh
68

7-
# Default to python3.8
8-
RUN ln -sf /usr/bin/python3.8 /usr/bin/python
9-
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
10-
RUN python get-pip.py
9+
# Install Python
10+
RUN apt-get install -y software-properties-common && \
11+
add-apt-repository ppa:deadsnakes/ppa -y && \
12+
apt-get update && \
13+
echo "MOD: python${PYTHON_VERSION}" && \
14+
apt-get install -y python${PYTHON_VERSION} && \
15+
ln -sf /usr/bin/python${PYTHON_VERSION} /usr/bin/python && \
16+
curl -sS https://bootstrap.pypa.io/get-pip.py | python && \
17+
/tmp/clean-layer.sh
1118

1219
RUN apt-get update && \
1320
apt-get install -y libzmq3-dev default-jdk && \
14-
apt-get install -y python3.8-dev libcurl4-openssl-dev libssl-dev && \
21+
apt-get install -y python${PYTHON_VERSION}-dev python3-venv libcurl4-openssl-dev libssl-dev && \
1522
pip install jupyter pycurl && \
1623
# Install older tornado - https://github.com/jupyter/notebook/issues/4437
1724
pip install "tornado<6" && \
@@ -33,11 +40,15 @@ RUN apt-get update && \
3340
/tmp/clean-layer.sh
3441

3542
# Miniconda
36-
RUN R -e 'reticulate::install_miniconda()'
37-
ENV RETICULATE_PYTHON=/root/.local/share/r-miniconda/envs/r-reticulate/bin/python
43+
ARG MINICONDA_PATH=/root/.local/share/r-miniconda
44+
ARG ENV_NAME=r-reticulate
45+
RUN R -e "reticulate::install_miniconda(path = \"${MINICONDA_PATH}\", update = TRUE, force = TRUE)"
46+
RUN R -e "reticulate::conda_create(envname = \"${ENV_NAME}\", conda = \"auto\", required = TRUE, python_version = \"${PYTHON_VERSION}\")"
47+
ENV RETICULATE_PYTHON="${MINICONDA_PATH}/envs/${ENV_NAME}/bin/python"
3848

3949
# Tensorflow and Keras
40-
RUN R -e 'keras::install_keras(tensorflow = "2.6", extra_packages = c("pandas", "numpy", "pycryptodome"), method="conda")'
50+
ARG TENSORFLOW_VERSION=2.11.0
51+
RUN R -e "keras::install_keras(tensorflow = \"${TENSORFLOW_VERSION}\", extra_packages = c(\"pandas\", \"numpy\", \"pycryptodome\"), method=\"conda\", envname=\"${ENV_NAME}\")"
4152

4253
# Install kaggle libraries.
4354
# Do this at the end to avoid rebuilding everything when any change is made.

gpu.Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ ENV CUDA_HOME=/usr/local/cuda
5656
ADD ldpaths $R_HOME/etc/ldpaths
5757

5858
# Install tensorflow with GPU support
59-
RUN R -e 'keras::install_keras(tensorflow = "gpu")' && \
59+
ARG TENSORFLOW_VERSION=2.11.0
60+
RUN R -e "keras::install_keras(version = \"${TENSORFLOW_VERSION}-gpu\", method = \"conda\", conda = \"auto\", envname=\"r-reticulate\")" && \
6061
rm -rf /tmp/tensorflow_gpu && \
6162
/tmp/clean-layer.sh
6263

package_installs.R

-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ install.packages("torch")
6060
library(torch)
6161
install_torch()
6262

63-
# The R Keras package must be reinstalled after installing it in the python virtualenv.
64-
install_version("keras", version = "2.6.0.0", ask=FALSE)
65-
6663
install.packages(c('collections', 'languageserver'), dependencies=TRUE)
6764

6865
# The tfhub package is added to the rcran image.

0 commit comments

Comments
 (0)