Skip to content

Commit b9553a8

Browse files
Add cuda12 variant of tensorflow-notebook (#2100)
* Add cuda12 variant for tensorflow-notebook * Reduce size of CPU version of tensorflow-notebook * Try to fix tests * Update docs/using/selecting.md Co-authored-by: Ayaz Salikhov <[email protected]> * Update images/tensorflow-notebook/cuda12/Dockerfile Co-authored-by: Ayaz Salikhov <[email protected]> * Update tests/docker-stacks-foundation/test_packages.py Co-authored-by: Ayaz Salikhov <[email protected]> * Remove obsolete XLA_FLAGS env var * Install CUDA and cuDNN using pip instead of mamba * Fix pre-commit shell checks * Change tensorflow variant name from cuda12 to cuda * Update selecting.md * Update selecting.md --------- Co-authored-by: Ayaz Salikhov <[email protected]>
1 parent dd06b93 commit b9553a8

File tree

6 files changed

+61
-7
lines changed

6 files changed

+61
-7
lines changed

.github/workflows/docker.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,17 @@ jobs:
196196
needs: [x86_64-scipy]
197197
if: ${{ !contains(github.event.pull_request.title, '[FAST_BUILD]') }}
198198

199+
x86_64-tensorflow-cuda:
200+
uses: ./.github/workflows/docker-build-test-upload.yml
201+
with:
202+
parent-image: scipy-notebook
203+
image: tensorflow-notebook
204+
variant: cuda
205+
platform: x86_64
206+
runs-on: ubuntu-latest
207+
needs: [x86_64-scipy]
208+
if: ${{ !contains(github.event.pull_request.title, '[FAST_BUILD]') }}
209+
199210
aarch64-pytorch:
200211
uses: ./.github/workflows/docker-build-test-upload.yml
201212
with:
@@ -378,6 +389,7 @@ jobs:
378389
{ image: r-notebook, variant: default },
379390
{ image: julia-notebook, variant: default },
380391
{ image: tensorflow-notebook, variant: default },
392+
{ image: tensorflow-notebook, variant: cuda },
381393
{ image: pytorch-notebook, variant: default },
382394
{ image: pytorch-notebook, variant: cuda11 },
383395
{ image: pytorch-notebook, variant: cuda12 },
@@ -439,6 +451,7 @@ jobs:
439451
{ image: r-notebook, variant: default },
440452
{ image: julia-notebook, variant: default },
441453
{ image: tensorflow-notebook, variant: default },
454+
{ image: tensorflow-notebook, variant: cuda },
442455
{ image: pytorch-notebook, variant: default },
443456
{ image: pytorch-notebook, variant: cuda11 },
444457
{ image: pytorch-notebook, variant: cuda12 },

docs/using/selecting.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ The following sections describe these images, including their contents, relation
1818

1919
## CUDA enabled variant
2020

21-
We provide CUDA accelerated version of `pytorch-notebook` image.
22-
Prepend a CUDA version prefix (like `cuda12-`) to the image tag to allow PyTorch operations to use compatible NVIDIA GPUs for accelerated computation.
23-
We only build images for 2 last major versions of CUDA.
21+
We provide CUDA accelerated version of `pytorch-notebook` and `tensorflow-notebook` images.
22+
Prepend a CUDA version prefix (like `cuda12-` for `pytorch-notebook` or `cuda-` for `tensorflow-notebook`) to the image tag
23+
to allow PyTorch or TensorFlow operations to use compatible NVIDIA GPUs for accelerated computation.
24+
Note: We only build `pytorch-notebook` for 2 last major versions of CUDA, `tensorflow-notebook` image only supports the latest CUDA version listed in the [officially tested build configurations](https://www.tensorflow.org/install/source#gpu).
2425

25-
For example, you can use an image `quay.io/jupyter/pytorch-notebook:cuda12-python-3.11.8`
26+
For example, you can use an image `quay.io/jupyter/pytorch-notebook:cuda12-python-3.11.8` or `quay.io/jupyter/tensorflow-notebook:cuda-latest`
2627

2728
### jupyter/docker-stacks-foundation
2829

images/tensorflow-notebook/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ LABEL maintainer="Jupyter Project <[email protected]>"
1111
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
1212
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1313

14-
# Install Tensorflow with pip
15-
RUN pip install --no-cache-dir tensorflow && \
14+
# Install tensorflow with pip, on x86_64 tensorflow-cpu
15+
RUN [[ $(uname -m) = x86_64 ]] && TF_POSTFIX="-cpu" || TF_POSTFIX="" && \
16+
pip install --no-cache-dir "tensorflow${TF_POSTFIX}" && \
1617
fix-permissions "${CONDA_DIR}" && \
1718
fix-permissions "/home/${NB_USER}"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=quay.io
4+
ARG OWNER=jupyter
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/scipy-notebook
6+
FROM $BASE_CONTAINER
7+
8+
LABEL maintainer="Jupyter Project <[email protected]>"
9+
10+
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
11+
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
12+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
13+
14+
# Install TensorFlow, CUDA and cuDNN with pip
15+
RUN pip install --no-cache-dir "tensorflow[and-cuda]" && \
16+
fix-permissions "${CONDA_DIR}" && \
17+
fix-permissions "/home/${NB_USER}"
18+
19+
# workaround for https://github.com/tensorflow/tensorflow/issues/63362
20+
RUN mkdir -p "${CONDA_DIR}/etc/conda/activate.d/" && \
21+
fix-permissions "${CONDA_DIR}"
22+
23+
COPY --chown="${NB_UID}:${NB_GID}" nvidia-lib-dirs.sh "${CONDA_DIR}/etc/conda/activate.d/"
24+
25+
# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html#dockerfiles
26+
ENV NVIDIA_VISIBLE_DEVICES="all" \
27+
NVIDIA_DRIVER_CAPABILITIES="compute,utility"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# Copyright (c) Jupyter Development Team.
3+
# Distributed under the terms of the Modified BSD License.
4+
5+
# This adds the NVIDIA libraries to the LD_LIBRARY_PATH. Workaround for
6+
# https://github.com/tensorflow/tensorflow/issues/63362
7+
NVIDIA_DIR=$(dirname "$(python -c 'import nvidia;print(nvidia.__file__)')")
8+
LD_LIBRARY_PATH=$(echo "${NVIDIA_DIR}"/*/lib/ | sed -r 's/\s+/:/g')${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
9+
export LD_LIBRARY_PATH

tagging/taggers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def tag_value(container: Container) -> str:
9898
class TensorflowVersionTagger(TaggerInterface):
9999
@staticmethod
100100
def tag_value(container: Container) -> str:
101-
return "tensorflow-" + _get_pip_package_version(container, "tensorflow")
101+
try:
102+
return "tensorflow-" + _get_pip_package_version(container, "tensorflow")
103+
except AssertionError:
104+
return "tensorflow-" + _get_pip_package_version(container, "tensorflow-cpu")
102105

103106

104107
class PytorchVersionTagger(TaggerInterface):

0 commit comments

Comments
 (0)