Build and run CaraML¶
Start from source: CaraML does not currently publish ready-to-install releases or a standalone Maven SDK. Check the license before commercial use.
1. Get the source¶
git clone https://github.com/Debanshu777/CaraML.git
cd CaraML
# Match the revision used to build these guides
git checkout --detach e5e579c0f047fae0495bd69d988bef675f459ac6
git submodule update --init
Initialize the two top-level native submodules at their pinned commits. Recursive initialization is unnecessary; optional nested upstream dependencies are outside CaraML's build graph. Do not update the engines to their latest branches to fix a build.
2. Install the tools¶
| Tool | Requirement |
|---|---|
| Java | Full JDK 21 with JNI headers; set JAVA_HOME to the JDK |
| Android SDK | Platform 37, used by the current Gradle configuration; target SDK remains 36, minimum device API 28 |
| Android NDK | 28.1.13356709 for the native engine |
| Android CMake | 3.31.1 |
| Desktop native tools | CMake 3.22.1 or newer and a C/C++ compiler; macOS needs Xcode command-line tools |
| iOS | macOS, full Xcode with an SDK supporting the configured iOS 17.2 deployment target; Apple Silicon simulator or arm64 device |
The Gradle wrapper supplies Gradle. The version catalog and native build configuration are authoritative when versions change.
The full Gradle build configures Android modules even when running desktop. Set ANDROID_HOME or create an untracked local.properties containing your actual sdk.dir. The portable SDK test path avoids app/native producer configuration.
Install the Android packages with Android Studio's SDK Manager, or with sdkmanager on your PATH:
sdkmanager "platforms;android-37" "platform-tools" "ndk;28.1.13356709" "cmake;3.31.1"
sdkmanager --licenses
3. Choose a platform¶
Desktop: macOS or Linux¶
./gradlew :app:desktopApp:run
Desktop distributions stage the selected native profile’s runtime libraries beside the application jars. JNI and backend discovery use the installed resources directory, so the app does not need the source checkout. Run ./gradlew :app:desktopApp:nativeRuntimeInstalledImageSmoke after packaging changes; it exercises the relocated filesystem and inference bridges without a model.
Windows MSVC builds apply the Microsoft STL mutex-constructor compatibility definition to the entire desktop native graph, including engine dependencies, because the host JVM can load an older C++ runtime. See Windows crash troubleshooting.
The run task builds the required native engines automatically. The first build downloads dependencies and compiles C++; subsequent runs reuse build outputs. macOS uses Metal; Linux's documented path uses CPU. Windows distribution tasks exist but still need release validation.
To build native code separately for diagnostics:
./gradlew :nativeEngine:compileLlamaRunnerDesktop
Android¶
For a first build without Vulkan header setup:
./gradlew :app:androidApp:assembleDebug -PcaramlAndroidBackend=cpu
adb install -r app/androidApp/build/outputs/apk/debug/androidApp-debug.apk
Use a connected Android device with USB debugging enabled, or an emulator. Physical hardware is needed for meaningful inference performance measurements.
The default build enables Vulkan on arm64 and packages an x86_64 CPU fallback. Install Vulkan and SPIR-V headers first:
# macOS
brew install vulkan-headers spirv-headers
# Debian/Ubuntu
sudo apt-get install libvulkan-dev spirv-headers
# Build with the default backend
./gradlew :app:androidApp:assembleDebug
The shader compiler comes from the NDK. CPU remains a runtime option. Vulkan support and benefit depend on the model and device. See native build details.
iOS¶
Open app/iosApp/iosApp.xcodeproj in Xcode. Select the scheme for the iosApp target and an arm64 simulator or device. Scheme names can differ in an existing checkout; xcodebuild -list -project app/iosApp/iosApp.xcodeproj lists them. For a physical device, select your own signing team. The Xcode build phase invokes the root Gradle wrapper and embeds the ComposeApp framework.
For separate native build diagnostics:
./gradlew :nativeEngine:mergeLlamaRunnerStaticIosArm64
./gradlew :nativeEngine:mergeLlamaRunnerStaticIosSimulatorArm64
Intel iOS simulators are not configured. The Kotlin framework and Xcode target use iOS 17.2 as the deployment minimum; use an Xcode SDK that can build it.
4. Have your first conversation¶
- Open Models from the navigation menu.
- Find a small instruct model in GGUF format. A small quantized model is a useful first smoke test; consult model selection.
- Inspect the exact files and size, then download. Track progress in Downloads in the Models app bar. Open the completed model from Downloads to return to its chat or generation workspace.
- Open Chat, select the downloaded model, and enter a short prompt such as
Give me three names for a robot gardener. - Use Stop to cancel a response. After download, local inference does not need a cloud service.
Model file size is not the same as working memory. If loading is refused, start with a smaller model or context; the troubleshooting guide explains common failures.
5. Generate an image¶
- In Models, open Filters, select Image, and apply the filter.
- Search for SD-Turbo. The Green-Sky/SD-Turbo-GGUF entry provides self-contained GGUF checkpoints for stable-diffusion.cpp.
- Review device fit, scroll through the variants, and select the recommended assessed file. Wait for the download and verification to finish.
- Open Images from the navigation menu. Once the model loads, enter a prompt such as
A tiny blue robot watering flowers in a sunny garden, clay art, soft lightingand generate.
Image models need additional memory for sampling and image decoding. A downloaded file can still exceed the device's current memory budget; use the app's assessment and model compatibility guide. The demo shows a real Pixel capture, while the benchmark overview links to measured diffusion workloads.
Avatar image dependencies¶
The shared app uses Coil Compose, SVG decoding and Ktor networking for Model Hub author avatars. Gradle resolves these from the version catalog; no image service token or extra platform setup is required. Android, iOS and desktop use their existing OkHttp, Darwin and CIO transport families.
Markdown rendering dependencies¶
Chat and model cards share the multiplatform Markdown renderer. The model-card reader adds the matching Coil3 adapter for images; both versions are pinned in gradle/libs.versions.toml. Gradle resolves these dependencies normally on Android, iOS, and JVM. There is no separate WebView or document-rendering setup.
Shared Java implementations and native test profiles¶
Android and JVM compile the same Java-compatible download and engine-bridge sources from src/javaMain/kotlin; their HTTP factories and native library loaders remain platform-specific. Kotlin supplies the standard library through its plugin. Discovery uses bounded manual JSON decoding, without a content-negotiation dependency. These are build/source simplifications and require no new setup.
App JVM tests resolve artifact_fs from the selected native producer profile. For a CPU desktop check, use ./gradlew :app:composeApp:jvmTest -PcaramlDesktopBackend=cpu; a prior default/Metal build is not required.