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.
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 |
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
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 |
Download |
---|
January 04, 2019 |
Note: Currently, the Xcode toolchains above only support macOS development. iOS/tvOS/watchOS are not supported.
- macOS 10.13.5 or later
- Xcode 10.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. 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 toLegacy Build System
.
-
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}"
-
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}"
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 18.04 (64-bit)
- Ubuntu 18.04 (64-bit)
- 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
- 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.)
- 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: 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.