-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BasicGradientDescent example crashes #22
Comments
Thanks for reporting. This is something we're tracking down right now. As you suspected, it's related to the use of loops in a differentiable function. When generating the derivative (pullback) of a differentiable function containing loops, a special memory allocation function is called in the Swift runtime. In mid-2023, we found that this function was leaking memory in specific cases, so a fix was provided in the form of a new allocator function. We used a new allocator function so as to not disrupt the operation of code that was using the old, leaky runtime function. Unfortunately, if you try to deploy code compiled with a new compiler to a macOS system with the old Swift runtime that lacks this, the program segfaults. Our instructions here for setting the This is only a problem with Swift toolchains newer than mid-September of 2023 and the command line on current macOS versions. It does not occur on Linux, when running in Xcode (which uses the toolchain Swift runtime), or with the 5.9 Swift toolchains from swift.org. Still, we're trying to get to the bottom of it. Sorry for the hassle. |
Extra note here. Running |
FWIW, it works ok for me:
|
The BasicGradientDescent example is crashing here with EXC_BAD_ACCESS on the first call to the loss function.
This is on an M1 MacBook with:
Xcode: 15.2
Toolchain: Swift Development Snapshot 2024-02-04 (a)
Project setup is via New Project with template MacOS Command Line Tool, then pasting your main.swift over the generated one.
(The other examples build and run correctly with this setup).
For some reason the crash can be fixed by unrolling the loop inside the loss function like this:
The text was updated successfully, but these errors were encountered: