tensorflow-script(Python)

Init script to install TensorFlow 1.13.1 or 2.0-alpha

This notebook creates an init script that installs TensorFlow.

  1. Import this notebook to your workspace.
  2. Set the script_path variable where you want to save the script.
  3. Set the TENSORFLOW_VERSION variable to the TensorFlow version you want to install:
    • TensorFlow 1.13.1: 'tensorflow-gpu==1.13.1'
    • TensorFlow 2.0-alpha: 'tensorflow-gpu==2.0.0-alpha0'
  4. Attach to a Python 3 cluster.
  5. Run this notebook (click Run All above). It generates a script named tensorflow-gpu-init.sh in script_path.
script_path="<init script location>"
script_name = script_path + "tensorflow-gpu-init.sh"

TENSORFLOW_VERSION = '<tensorflow version>'
script="""#!/bin/bash

set -e

/databricks/python/bin/python -V

. /databricks/conda/etc/profile.d/conda.sh

conda activate /databricks/python

conda uninstall -y cudnn

conda install -y -c anaconda cudatoolkit=10.0

DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq --no-install-recommends \
    libcudnn7=7.5.0.56-1+cuda10.0  \
    libcudnn7-dev=7.5.0.56-1+cuda10.0

/databricks/python/bin/pip install {tfversion}
""".format(tfversion=TENSORFLOW_VERSION)
dbutils.fs.put(script_name, script, True)