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
which provides an easy to use wrapper for the various steps required to install
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:
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.
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:
|auto||Automatically choose an appropriate default for the current platform.|
|virtualenv||Install into a Python virtual environment at |
|conda||Install into an Anaconda Python environment named |
|system||Install 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() install the latest release version of TensorFlow. You can override this behavior by specifying the
version parameter. For example:
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:
You can install any other build of TensorFlow by specifying a URL to a TensorFlow binary. For example: