Quick start

    Prior to using the tensorflow R package you need to install a version of TensorFlow on your system. Below we describe how to install TensorFlow as well the various options available for customizing your installation.

    Note that this article principally covers the use of the R install_tensorflow() function, which provides an easy to use wrapper for the various steps required to install TensorFlow.

    You can also choose to install TensorFlow manually (as described at https://www.tensorflow.org/install/). In that case the Custom Installation section covers how to arrange for the tensorflow R package to use the version you installed.

    TensorFlow is tested and supported on the following 64-bit systems:

    • Ubuntu 16.04 or later
    • Windows 7 or later
    • macOS 10.12.6 (Sierra) or later (no GPU support)


    First, install the tensorflow R package from GitHub as follows:


    Then, use the install_tensorflow() function to install TensorFlow. Note that on Windows you need a working installation of Anaconda.

    You can confirm that the installation succeeded with:

    ## tf.Tensor(b'Hellow Tensorflow', shape=(), dtype=string)

    This will provide you with a default installation of TensorFlow suitable for use with the tensorflow R package. Read on if you want to learn about additional installation options, including installing a version of TensorFlow that takes advantage of Nvidia GPUs if you have the correct CUDA libraries installed.

    Installation methods

    TensorFlow is distributed as a Python package and so needs to be installed within a Python environment on your system. By default, the install_tensorflow() function attempts to install TensorFlow within an isolated Python environment (“r-reticulate”).

    These are the available methods and their behavior:

    autoAutomatically choose an appropriate default for the current platform.
    virtualenvInstall into a Python virtual environment at ~/.virtualenvs/r-reticulate
    condaInstall into an Anaconda Python environment named r-reticulate
    systemInstall into the system Python environment

    The “virtualenv” and “conda” methods are available on Linux and OS X and only the “conda” method is available on Windows.

    install_tensorflow is a wraper around reticulate::py_install. Please refer to ‘Installing Python Packages’ for more information.

    Alternate Versions

    By default, install_tensorflow() install the latest release version of TensorFlow. You can override this behavior by specifying the version parameter. For example:

    install_tensorflow(version = "2.0.0")

    Note that this should be a full major.minor.patch version specification (rather than just major and minor versions).

    You can install the nightly build of TensorFlow (CPU or GPU version) with:

    install_tensorflow(version = "nightly")      # cpu version
    install_tensorflow(version = "nightly-gpu")  # gpu version

    You can install any other build of TensorFlow by specifying a URL to a TensorFlow binary. For example:

    install_tensorflow(version = "https://files.pythonhosted.org/packages/c2/c1/a035e377cf5a5b90eff27f096448fa5c5a90cbcf13b7eb0673df888f2c2d/tf_nightly-1.12.0.dev20180918-cp36-cp36m-manylinux1_x86_64.whl")