I have a MacBook Pro M3 Pro with 18GB of RAM and was following the instructions to fine tune the foundational model given here: https://developer.apple.com/apple-intelligence/foundation-models-adapter/
However, while following the code sample in the example Jupyter notebook, my Mac hangs on the second code cell. Specifically:
from examples.generate import generate_content, GenerationConfiguration
from examples.data import Message
output = generate_content(
[[
Message.from_system("A conversation between a user and a helpful assistant. Taking the role as a play writer assistant for a kids' play."),
Message.from_user("Write a script about penguins.")
]],
GenerationConfiguration(temperature=0.0, max_new_tokens=128)
)
output[0].response
After some debugging, I was getting the following error:
RuntimeError: MPS backend out of memory (MPS allocated: 22.64 GB, other allocations: 5.78 MB, max allowed: 22.64 GB). Tried to allocate 52.00 MB on private pool. Use PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 to disable upper limit for memory allocations (may cause system failure).
So is my machine not capable enough to adapter train Apple's Foundation Model? And if so, what's the recommended spec and could this be specified somewhere? Thanks!
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello!
I'm following the Foundation Models adapter training guide (https://developer.apple.com/apple-intelligence/foundation-models-adapter/) on my NVIDIA DGX Spark box. I'm able to train on my own data but the example notebook fails when I try to export the artifact as an fmadapter. I get the following error for the code block I'm trying to run. I haven't touched any of the code in the export folder. I tried exporting it on my Mac too and got the same error as well (given below). Would appreciate some more clarity around this. Thank you.
Code Block:
from export.export_fmadapter import Metadata, export_fmadapter
metadata = Metadata(
author="3P developer",
description="An adapter that writes play scripts.",
)
export_fmadapter(
output_dir="./",
adapter_name="myPlaywritingAdapter",
metadata=metadata,
checkpoint="adapter-final.pt",
draft_checkpoint="draft-model-final.pt",
)
Error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[10], line 1
----> 1 from export.export_fmadapter import Metadata, export_fmadapter
3 metadata = Metadata(
4 author="3P developer",
5 description="An adapter that writes play scripts.",
6 )
8 export_fmadapter(
9 output_dir="./",
10 adapter_name="myPlaywritingAdapter",
(...) 13 draft_checkpoint="draft-model-final.pt",
14 )
File /workspace/export/export_fmadapter.py:11
8 from typing import Any
10 from .constants import BASE_SIGNATURE, MIL_PATH
---> 11 from .export_utils import AdapterConverter, AdapterSpec, DraftModelConverter, camelize
13 logger = logging.getLogger(__name__)
16 class MetadataKeys(enum.StrEnum):
File /workspace/export/export_utils.py:15
13 import torch
14 import yaml
---> 15 from coremltools.libmilstoragepython import _BlobStorageWriter as BlobWriter
16 from coremltools.models.neural_network.quantization_utils import _get_kmeans_lookup_table_and_weight
17 from coremltools.optimize._utils import LutParams
ModuleNotFoundError: No module named 'coremltools.libmilstoragepython'
Hello!
I was wondering if it would be possible for the developers to post the sample code for the Face Mesh demo that used PencilKit to draw a filter on a user's face.
I have a Reality Composer project that has two scenes. In the first scene, I post a notification from Xcode to trigger an animation and then change the scene to the next scene. This is done using the Change Scene in the Action Sequence.
In the second scene, when the user taps on an object, it should send a notification to Xcode using the Notify action. How do I set the .onAction in Xcode for the second scene if I switch to the second scene using an Action Sequence from the first scene? Thanks!
Hello!
I've been trying to replicate the linear regressor tabular application as shown at the end of the WWDC 2021 session Build dynamic iOS apps with the Create ML framework. However, I keep getting the error
Cannot find 'DataFrame' in scope and Cannot find 'Column' in scope.
I was wondering if this is a bug with the current beta or if I have my code wrong. I am trying to run my application on an iPhone 12 Pro running iOS 15 Beta 1. I am using Xcode 13 on Monterey. Thank you!
Hello!
I was wondering if it would be possible for the sample code for the Meal App to be posted. There are some things I'd like to see regarding MLLinearRegressor and how models can be personalized with context and data.
Hello!
I really want to make these immersive AR experiences with engaging graphics like the new AR Spaces feature in the Clips app. Is RealityKit the way to go for this? Or does it require some really lower level understanding and use of API’s like ARKit with Metal?
Also, with RealityKit’s scene understanding, we can map a mesh of the scene the LIDAR device can see but I was wondering how would I switch that out with a custom mesh design like in the Clips app as well.
Thank you!
Hello!
I want to build an app that lets devices with the LiDAR Scanner scan their environment and share their scans with one another. As of now, I can create the mesh using the LiDAR Scanner and export it as an OBJ file.
However, I would like the ability to map textures and colors onto this model. How would one go on to get the real world texture and place it onto the OBJ model?
Thank you!
Hi!
Wondering if there's a way to add subject lifting to images in my SwiftUI app without relying on UIViewControllerRepresentable and Coordinators to adopt the ImageAnalysisInteraction protocol.
Thank you!
I have a horizontal scroll view and a fixed array. I would like to loop it such that when I scroll left and get near the end, the array will add the items in the beginning to the end so that the user can continue to scroll. I would like this to happen when scrolling both left and right and to not have the current position of the user jump around. Here is my code. What am I missing? Would appreciate any and all help.
import SwiftUI
import Algorithms
struct ContentView: View {
@State private var timePosition = ScrollPosition(idType: Int.self, edge: .leading)
@State private var times: [Int] = Array(0...23)
var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(spacing: 0) {
ForEach(times, id:\.self) { time in
Text("\(time)")
.font(.system(.callout, design: .monospaced, weight: .semibold))
.padding(8)
.frame(width: 180, height: 110, alignment: .topLeading)
.border(width: 1, edges: [.leading, .trailing], color: .primary.opacity(0.05))
.id(time)
}
}
.scrollTargetLayout()
}
.frame(height: 110)
.scrollPosition($timeScrollPosition, anchor: .center)
.onScrollTargetVisibilityChange(idType: Int.self) { timeIDs in
if let currentViewID = model.timeScrollPosition.viewID {
if timeIDs.contains(times[times.count - 2]) {
times.rotate(toStartAt: times.count - 1)
}
if timeIDs.contains(times[1]) {
times.rotate(toStartAt: times.count-1)
}
print("New times: \(times)")
timeScrollPosition.scrollTo(id: currentViewID)
}
}
}
}