RStudio is now Posit!
Our professional products have been renamed to Posit Connect, Posit Workbench, Posit Package Manager, Posit Cloud, and Posit Academy so it’s easier for folks to understand that we support more than just R. Please review our Blog post/FAQ to answer commonly asked questions about the rebrand.
Deprecation Notice
Starting in RStudio Connect 2022.09.0, TensorFlow Model API hosting is deprecated and will be removed in an upcoming release. Use an API framework like Plumber, Flask, or FastAPI to create an HTTP API for your TensorFlow model.
Install TensorFlow Dependencies#
The TensorFlow C library libtensorflow.so
is required for TensorFlow Model
API deployment support. The version of libtensorflow.so
must match the
version supported by Posit Connect, formerly RStudio Connect, currently 1.15.0.
If users are experiencing difficulty deploying TensorFlow Models to Connect, verify that the correct version of libtensorflow.so
is installed.
Note
TensorFlow 2.x is not supported by Connect.
To install the TensorFlow dependencies, first verify that your license supports TensorFlow Model API deployment. If you do not have a Standard or Enterprise license, please contact your Customer Success Representative or Posit Sales (sales@posit.co) for information about upgrading your license.
Second, verify that your platform is supported by TensorFlow. TensorFlow requires libraries that are unavailable on CentOS 6, Red Hat Enterprise Linux 6, and SUSE Linux Enterprise Server 12. Accordingly, Connect does not provide support for running TensorFlow Model APIs on these platforms and no longer supports CentOS 6.
Next, determine what version of TensorFlow your users will be deploying their models with. Connect supports TensorFlow versions 1.15.0 and earlier. Later releases and development TensorFlow builds are not supported.
Finally, there are two options for installing the required libraries:
-
Install a
libtensorflow
binary package. This binary installation is not optimized for your platform, but provides a working runtime for TensorFlow Model APIs on Connect. Follow the TensorFlow Binary Packages instructions. -
Compile
libtensorflow
from source. You can customize the compilation of the library so it is optimized for your hardware. Follow the Compiling TensorFlow Libraries From Source instructions.
TensorFlow Binary Packages#
The guide Installing TensorFlow For C should contain a Setup section with Download and Extract subsections to download and extract the TensorFlow C library.
Follow the instructions up to that point, download and extract the binary, and then:
-
On Ubuntu, the libraries may need to be installed to
/usr/lib
rather than/usr/local/lib
as specified in the instructions. -
On RHEL/CentOS, the libraries need to be installed to
/usr/lib64
rather than/usr/local/lib
as specified in the instructions. -
On ALL PLATFORMS: Ensure that both
libtensorflow.so
andlibtensorflow_framework.so
are in your shared library search path. -
After installing the shared libraries, configure the linker with
ldconfig
:Terminalsudo ldconfig
-
Connect will detect your TensorFlow installation after a restart.
Terminalsudo systemctl restart rstudio-connect
Info
Your platform may use alternate commands to restart Connect. Please see the Stopping and Starting section for instructions specific to your operating system version.
Compiling TensorFlow Libraries From Source#
Note
- These instructions have been tested as of TensorFlow 1.13.1, please refer to the TensorFlow Project for up-to-date information on building TensorFlow Libraries.
- Compiling TensorFlow from source may be difficult and is highly dependent
on your host environment. If you encounter issues compiling
libtensorflow.so
from source, you should raise an issue at the TensorFlow project's Github Issues Page.
-
Install Bazel per the Bazel Installation Instructions
-
Download the TensorFlow Source either using
git clone
or by downloading a source tarball. -
Check out version 1.13.1 with git.
git checkout v1.13.1
-
Python, Swig, and NumPy may be required on the build platform.
- On Ubuntu, they can be installed with
sudo apt-get install python swig python-numpy
- On CentOS, they can be installed with
sudo yum install python swig numpy
- On Ubuntu, they can be installed with
-
Enter the source directory and run
./configure
. Answer the questions about your hardware to the best of your knowledge. Application logs will contain a warning if the platform's tensorflow libraries lack usable optimizations. -
Execute
bazel build --config opt //tensorflow:libtensorflow.so
. This will compile tensorflow for your platform -
Copy
libtensorflow.so
andlibtensorflow_framework.so
frombazel-bin/tensorflow
into your platform's shared library path -
After installing the shared libraries, configure the linker with
ldconfig
:sudo ldconfig
-
Connect will detect your TensorFlow installation after a restart.
sudo systemctl restart rstudio-connect
Info
Your platform may use alternate commands to restart Connect. Please see the Stopping and Starting section for instructions specific to your operating system version.