This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import PythonKit | |
// Replace the path below with where your Python is located. | |
//PythonLibrary.useLibrary(at: "/Users/philipturner/miniforge3/bin/python") | |
let torch = Python.import("torch") | |
let nn = torch.nn | |
let DataLoader = torch.utils.data.DataLoader | |
let torchvision = Python.import("torchvision") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////// model_training_walkthrough.ipynb | |
// ======================================================== | |
import TensorFlow | |
import PythonKit | |
import Foundation | |
import FoundationNetworking | |
func download(from sourceString: String, to destinationString: String) { | |
let source = URL(string: sourceString)! | |
let destination = URL(fileURLWithPath: destinationString) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tensorflow_version="2.9.1" | |
DESTDIR=${PWD}/Library/tensorflow-${tensorflow_version} | |
if [[ $(uname -s) == "Darwin" ]]; then | |
lib_end="dylib" # macOS | |
else | |
lib_end="so" # Linux | |
fi | |
# ===----------------------------------------------------------------------=== # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if canImport(Darwin) // Apple platforms | |
import OpenCL | |
#else | |
// Don't know how to import OpenCL on Linux yet. It should be possible if I | |
// wrap it in a Clang module and link that to Swift. | |
#endif | |
/* | |
Sourced from this online tutorial: | |
https://www.eriksmistad.no/getting-started-with-opencl-and-gpu-computing/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I suspect that the crash is caused by a memory leak at runtime. It keeps | |
// crashing at random places. Once, it even crashed at the end of `llvm::orc:: | |
// runAsMain`. | |
// I transformed it into a cast that I am 100% sure is allowed, and it still | |
// crashed, but less than 100% of the time. In the possibly illegal form, it | |
// crashed exactly 100% of the time. | |
// It seems like a valid cast in the code. It is a differentiable_function_expr | |
// but it is cached somewhere. I noticed that removing the previous declaration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _Differentiation | |
func myFunc(x: Float, y: Float) -> Float { x + y } | |
let item: @differentiable(reverse) (Float, Float) -> Float = myFunc | |
class Box<T> { | |
var value: T | |
init(value: T) { | |
self.value = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prepare for building S4TF | |
# Ensure this is your toolchain's bundle identifier. The one hard-coded is for | |
# May 4, 2022. That may not be your toolchain. | |
export TOOLCHAINS="org.swift.57202205041a" | |
# I plan to upgrade to v2.9.0-rc2 soon, so you may need to change this part of | |
# the script soon. | |
tensorflow_version="2.8.0" | |
# What ever directory this script is in, should contain the unzipped "Library" | |
# folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macOS 13, 10c CPU, 32c GPU, 1 TB SSD | |
| | | +-o AGXAcceleratorG13X <class AGXAcceleratorG13X, id 0x100000983, registered, matched, active, busy 0 (11866 ms), retain 77> | |
| | | | { | |
| | | | "SchedulerState" = {"Stamps"=(),"BusyWorkQueues"=()} | |
| | | | "IOMatchedAtBoot" = Yes | |
| | | | "vendor-id" = <6b100000> | |
| | | | "GPURawCounterBundleName" = "AGXGPURawCounterBundle" | |
| | | | "MetalStatisticsName" = "AGXMetalStatisticsExternalA14X" | |
| | | | "AGXParameterBufferMaxSizeEverMemless" = 1149763584 |
OlderNewer