|
| 1 | +# Ubuntu 22.04 Python3 with CUDA 11 and the following: |
| 2 | +# - Installs tf-nightly-gpu (this is TF 2.3) |
| 3 | +# - Installs requirements.txt for tensorflow/models |
| 4 | + |
| 5 | +FROM nvidia/cuda:12.2.0-devel-ubuntu20.04 as base |
| 6 | +ARG tensorflow_pip_spec="tf-nightly" |
| 7 | +ARG local_tensorflow_pip_spec="" |
| 8 | +ARG extra_pip_specs="" |
| 9 | +ENV PIP_CMD="python3.11 -m pip" |
| 10 | + |
| 11 | +# setup.py passes the base path of local .whl file is chosen for the docker image. |
| 12 | +# Otherwise passes an empty existing file from the context. |
| 13 | +COPY ${local_tensorflow_pip_spec} /${local_tensorflow_pip_spec} |
| 14 | + |
| 15 | +# Pick up some TF dependencies |
| 16 | +# cublas-dev and libcudnn7-dev only needed because of libnvinfer-dev which may not |
| 17 | +# really be needed. |
| 18 | +# In the future, add the following lines in a shell script running on the |
| 19 | +# benchmark vm to get the available dependent versions when updating cuda |
| 20 | +# version (e.g to 10.2 or something later): |
| 21 | +# sudo apt-cache search cuda-command-line-tool |
| 22 | +# sudo apt-cache search cuda-cublas |
| 23 | +# sudo apt-cache search cuda-cufft |
| 24 | +# sudo apt-cache search cuda-curand |
| 25 | +# sudo apt-cache search cuda-cusolver |
| 26 | +# sudo apt-cache search cuda-cusparse |
| 27 | + |
| 28 | +# Needed to disable prompts during installation. |
| 29 | +ENV DEBIAN_FRONTEND noninteractive |
| 30 | + |
| 31 | + |
| 32 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 33 | + libfreetype6-dev \ |
| 34 | + libhdf5-serial-dev \ |
| 35 | + libzmq3-dev \ |
| 36 | + libpng-dev \ |
| 37 | + pkg-config \ |
| 38 | + software-properties-common \ |
| 39 | + unzip \ |
| 40 | + lsb-core \ |
| 41 | + curl |
| 42 | + |
| 43 | +# Python 3.11 related deps in this ppa. |
| 44 | + |
| 45 | +RUN add-apt-repository ppa:deadsnakes/ppa |
| 46 | + |
| 47 | + |
| 48 | +# Install / update Python and Python3 |
| 49 | +RUN apt-get install -y --no-install-recommends \ |
| 50 | + python3.11 \ |
| 51 | + python3-pip \ |
| 52 | + python3.11-dev \ |
| 53 | + python3-setuptools \ |
| 54 | + python3.11-venv \ |
| 55 | + python3.11-distutils \ |
| 56 | + python3.11-lib2to3 |
| 57 | + |
| 58 | +RUN python3.11 -m ensurepip --upgrade |
| 59 | + |
| 60 | +# Upgrade pip, need to use pip3 and then pip after this or an error |
| 61 | +# is thrown for no main found. |
| 62 | +RUN ${PIP_CMD} install --upgrade pip |
| 63 | +RUN ${PIP_CMD} install --upgrade distlib |
| 64 | +# setuptools upgraded to fix install requirements from model garden. |
| 65 | +RUN ${PIP_CMD} install --upgrade setuptools |
| 66 | + |
| 67 | +# For CUDA profiling, TensorFlow requires CUPTI. |
| 68 | +ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda-11.2/lib64:$LD_LIBRARY_PATH |
| 69 | + |
| 70 | +# See http://bugs.python.org/issue19846 |
| 71 | +ENV LANG C.UTF-8 |
| 72 | + |
| 73 | +# Add google-cloud-sdk to the source list |
| 74 | +# Note: use "cloud-sdk" instead of "cloud-sdk-$(lsb_release -c -s)" to resolve "'http://packages.cloud.google.com/apt cloud-sdk-focal Release' does not have a Release file |
| 75 | +RUN echo "deb http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list |
| 76 | +RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - |
| 77 | + |
| 78 | +# Install extras needed by most models |
| 79 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 80 | + git \ |
| 81 | + ca-certificates \ |
| 82 | + wget \ |
| 83 | + htop \ |
| 84 | + zip \ |
| 85 | + google-cloud-sdk |
| 86 | + |
| 87 | +RUN ${PIP_CMD} install --upgrade pyyaml |
| 88 | +RUN ${PIP_CMD} install --upgrade google-api-python-client==1.8.0 |
| 89 | +RUN ${PIP_CMD} install --upgrade google-cloud google-cloud-bigquery google-cloud-datastore mock |
| 90 | + |
| 91 | + |
| 92 | +RUN ${PIP_CMD} install wheel |
| 93 | +RUN ${PIP_CMD} install absl-py |
| 94 | +RUN ${PIP_CMD} install --upgrade --force-reinstall ${tensorflow_pip_spec} ${extra_pip_specs} |
| 95 | + |
| 96 | +RUN ${PIP_CMD} install tfds-nightly |
| 97 | +RUN ${PIP_CMD} install -U scikit-learn |
| 98 | + |
| 99 | +# Install dependnecies needed for tf.distribute test utils |
| 100 | +RUN ${PIP_CMD} install dill tblib portpicker |
| 101 | + |
| 102 | +RUN curl https://raw.githubusercontent.com/tensorflow/models/master/official/nightly_requirements.txt > /tmp/requirements.txt |
| 103 | +RUN ${PIP_CMD} install -r /tmp/requirements.txt |
| 104 | + |
| 105 | +RUN ${PIP_CMD} install tf-estimator-nightly |
| 106 | +RUN ${PIP_CMD} install tensorflow-text-nightly |
| 107 | + |
| 108 | +# RUN nvidia-smi |
| 109 | + |
| 110 | +RUN nvcc --version |
| 111 | + |
| 112 | + |
| 113 | +RUN ${PIP_CMD} freeze |
0 commit comments