Skip to content

Latest commit

 

History

History
162 lines (109 loc) · 8.77 KB

Installation.md

File metadata and controls

162 lines (109 loc) · 8.77 KB

Install Swift for TensorFlow

To install Swift for TensorFlow, download one of the packages below and follow the instructions for your operating system. After installation, you can use the full suite of Swift tools, including swift (Swift REPL/interpreter) and swiftc (Swift compiler). See here for more details about using Swift for TensorFlow.

Note:

  • If you want to modify the Swift for TensorFlow source code or build with a custom version of TensorFlow, see here for instructions on building from source.
  • Swift for TensorFlow is an early stage project. It has been released to enable open source development and is not yet ready for general use by machine learning developers.

Releases

Download Version Date
Xcode 10 v0.3.1 April 30, 2019
Ubuntu 18.04 (CPU Only) v0.3.1 April 30, 2019
Ubuntu 18.04 (CUDA 10.0) v0.3.1 April 30, 2019
Ubuntu 18.04 (CUDA 9.2) v0.3.1 April 30, 2019
Older Packages
Download Version Date
Xcode 10 v0.3 April 23, 2019
Ubuntu 18.04 (CPU Only) v0.3 April 23, 2019
Ubuntu 18.04 (CUDA 10.0) v0.3 April 23, 2019
Ubuntu 18.04 (CUDA 9.2) v0.3 April 23, 2019
Download Version Date
Xcode 10 v0.2 March 1, 2019
Ubuntu 18.04 (CPU Only) v0.2 March 1, 2019
Ubuntu 18.04 (CUDA 10.0) v0.2 March 1, 2019
Ubuntu 18.04 (CUDA 9.2) v0.2 March 1, 2019

Development Snapshots

Download Date
Xcode 10 April 18, 2019
Ubuntu 18.04 (CPU Only) Nightly
Ubuntu 18.04 (CUDA 10.0) Nightly
Ubuntu 18.04 (CUDA 9.2) Nightly
Older Packages

Xcode

Xcode 10

Download
April 16, 2019
March 26, 2019
March 23, 2019
February 25, 2019
February 20, 2019
February 18, 2019
February 13, 2019
February 10, 2019
January 04, 2019

Ubuntu 16.04

Download
January 04, 2019

Note: Currently, the Xcode toolchains above only support macOS development. iOS/tvOS/watchOS are not supported.

Using Downloads

macOS

Requirements

  • macOS 10.13.5 or later
  • Xcode 10.0 beta or later

Installation

  1. Download the latest package release.

  2. Run the package installer, which will install an Xcode toolchain into /Library/Developer/Toolchains/.

  3. An Xcode toolchain (.xctoolchain) includes a copy of the compiler, lldb, and other related tools needed to provide a cohesive development experience for working in a specific version of Swift.

  4. Open Xcode’s Preferences, navigate to Components > Toolchains, and select the installed Swift for TensorFlow toolchain.

  5. Xcode uses the selected toolchain for building Swift code, debugging, and even code completion and syntax coloring. You’ll see a new toolchain indicator in Xcode’s toolbar when Xcode is using a Swift toolchain. Select the Xcode toolchain to go back to Xcode’s built-in tools. Note: in Xcode 10, you may also have to switch to the legacy build system. In Xcode go to File > Project Settings and set the build system to Legacy Build System.

Select toolchain in Xcode preferences.

  1. Selecting a Swift toolchain affects the Xcode IDE only. To use the Swift toolchain with command-line tools, add the Swift toolchain to your path as follows:

    $ export PATH=/Library/Developer/Toolchains/swift-latest/usr/bin:"${PATH}"
  2. CUDA-only: If you downloaded a CUDA GPU version of the toolchain, add the library path(s) to CUDA and CuDNN to $LD_LIBRARY_PATH.

    $ export LD_LIBRARY_PATH=/usr/local/cuda/lib:"${LD_LIBRARY_PATH}"

Linux

Packages for Linux are tar archives including a copy of the Swift compiler, lldb, and related tools. You can install them anywhere as long as the extracted tools are in your PATH. Note that nothing prevents Swift from being ported to other Linux distributions beyond the ones mentioned below. These are only the distributions where these binaries have been built and tested.

Requirements

  • Ubuntu 18.04 (64-bit)

Supported Target Platforms

  • Ubuntu 18.04 (64-bit)

Additional Requirements

  • For GPU toolchains:
    • CUDA Toolkit 9.2 or 10.0
    • CuDNN 7.1 (CUDA 9.2) or 7.3.x onwards (CUDA 10.0)
    • An NVIDIA GPU with compute compatibility 3.5 or 7.0

Installation

  1. Install required dependencies:
$ sudo apt-get install clang libpython-dev libblocksruntime-dev

(Note: You may also need to install other dependencies, if you are unable to run swift or other tools below.)

  1. Download the latest binary release above.

The swift-tensorflow-<VERSION>-<PLATFORM>.tar.gz file is the toolchain itself.

  1. Extract the archive with the following command:
$ tar xzf swift-tensorflow-<VERSION>-<PLATFORM>.tar.gz

This creates a usr/ directory in the location of the archive.

  1. Add the Swift toolchain to your path as follows:
$ export PATH=$(pwd)/usr/bin:"${PATH}"

You can now execute the swift command to run the REPL or build Swift projects.

Note: If you are using a CUDA build and you have an NVIDIA GPU with a compute capability other than 3.5 or 7.0, then you will experience a ~10 minute delay the first time you execute a TensorFlow operation, while TensorFlow compiles kernels for your GPU's compute capability. The program will not print anything out and it will appear to be frozen.