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.
Note: Swift for TensorFlow is an early stage research project. It has been released to enable open source development and is not yet ready for general use by machine learning developers.
Packages will be released nightly after automated building is set up.
Download | Date |
---|---|
Xcode | April 26, 2018 |
Ubuntu 16.04 | April 26, 2018 |
Ubuntu 14.04 | April 26, 2018 |
Note: Currently, the Xcode toolchains above only support macOS development. iOS/tvOS/watchOS are not supported.
- macOS 10.12.4 or later
- Xcode 9.0 beta or later
-
Download the latest package release.
-
Run the package installer, which will install an Xcode toolchain into
/Library/Developer/Toolchains/
. -
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. -
Open Xcode’s
Preferences
, navigate toComponents > Toolchains
, and select the installed Swift for TensorFlow toolchain. -
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.
- 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}"
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.
- Ubuntu 14.04 or 16.04 (64-bit)
- Ubuntu 14.04 or 16.04 (64-bit)
- Install required dependencies:
$ sudo apt-get install clang libicu-dev libpython-dev libncurses5-dev
- Download the latest binary release above.
The swift-tensorflow-<VERSION>-<PLATFORM>.tar.gz
file is the toolchain itself.
- 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.
- 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: when running the REPL on Ubuntu, you must manually specify the include path to clang
headers:
swift -I/<path-to-toolchain>/usr/lib/swift/clang/include
This is a necessary workaround for SR-5524, a bug causing modulemap imports to fail in the REPL.