Git Product home page Git Product logo

swiftrt's Introduction


Overview

SwiftRT is an experimental computational framework written in the Swift language. The project is under heavy devopment, so frequent changes should be expected.


Installation

This project requires the use of the Google Swift for TensorFlow custom toolchain (in place of the standard toolchain), because it leverages the toolchain's integrated auto differentiation functionality.

MacOS and Ubuntu CPU Only Installation

Currently a cpu build is available on MacOS.

  1. Install Xcode 12

  2. Install the Google Swift for TensorFlow Xcode 12 Toolchain, and in Xcode select the toolchain in the Preferences pane.

  3. Install and run the SwiftRT unit tests to verify the installation:

$ git clone https://github.com/ewconnell/swiftrt.git
$ cd swiftrt
$ swift test
  1. To create an Xcode project for debugging
$ swift package generate-xcodeproj

Ubuntu Cuda Installation

Currently the Swift Package Manager does not support building .cpp or cuda .cu files, so CMake is used. CMake and the SPM are used in combination in order to resolve dependent packages during build.

NOTE: all unit tests should pass with the CPU only build. The Cuda version is currently under development and there is no claim that the unit tests currently pass. This notice will be removed after they successfully pass.

  1. Install CUDA 11.0 and cuDNN with CUDA 11.0 support.

    Note: SwiftRT expects cuddn.h to be available from within /usr/local/cuda/include directory. If you install cudnn via the deb package, you might have to symlink it manually.

  2. Install the latest development snapshot of the Google Swift for TensorFlow Toolchain with CUDA 11.0.

  3. Add the following exports to your ~/.bashrc file, assuming SwiftRT installation is in the $HOME directory.

# swiftrt installation location
export SWIFTRT_HOME=$HOME/swiftrt

# add to pkgconfig path location of .pc files so SPM can link to Cuda
export PKG_CONFIG_PATH=$SWIFTRT_HOME/pkgconfig

# add `gyb` utility to path if you will be modifying the SwiftRT codebase
# and changing any .gyb files.
export PATH=$SWIFTRT_HOME/gyb:$PATH

# tells Package.swift to include a dependency and link to cuda
export SWIFTRT_PLATFORM=cuda

# cuda installation location
export CUDA_ROOT=/usr/local/cuda
export LIBRARY_PATH=$CUDA_ROOT/lib64

# to enable LLDB to find Cuda symbols
export C_INCLUDE_PATH=$CUDA_ROOT/include
export CPLUS_INCLUDE_PATH=$CUDA_ROOT/include
  1. CMake 3.18 or higher is required to build. If your current version is less than 3.18, download and install the latest version.

  2. To configure cmake for a Debug version

$ cd $SWIFTRT_HOME
$ mkdir build
$ cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=$SWIFT_HOME/usr/bin/clang-10 -H$SWIFTRT_HOME -B$SWIFTRT_HOME/build -DSWIFTRT_ENABLE_CUDA:BOOL=YES -G Ninja
  1. To build
$ cd $SWIFTRT_HOME
$ cmake --build ./build --target SwiftRTTestRunner
  1. To clean
$ cd $SWIFTRT_HOME
$ cmake --build ./build --target clean
$ rm -rf .build

Setting up VScode

VScode is the only IDE so far that seems to be able to build and debug using the custom S4TF toolchain.

  1. Install VScode
  2. The following extensions seem to work.
  • Swift Language (Martin Kase)
  • CMake Tools (Microsoft)
  • CodeLLDB (Vadim Chugunov)
    • It is very important that settings.json contains the following entry to pickup the correct lldb version from the toolchain. Substituting PathToSwiftToolchain with wherever you installed the toolchain.
    {
        "lldb.library": "PathToSwiftToolchain/usr/lib/liblldb.so"
    }
  • SourceKit-LSP (Pavel Vasek)
    • There is a version of the server as part of the toolchain already, so you don't need to build it. Make sure to configure the extension
    "sourcekit-lsp.serverPath": "PathToSwiftToolchain/usr/bin/sourcekit-lsp"
  • Subtle Match Brackets (Rafa Mel)
  • vscode-cudacpp (kriegalex)
  1. The $SWIFTRT_HOME/Documents/vscode directory contains some helpful starter examples (launch and tasks) to configure the development environment.

swiftrt's People

Contributors

bradlarson avatar compnerd avatar dan-zheng avatar ewconnell avatar saeta avatar shabalind avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.