Skip to content
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

Gradle Run Task Fails with SIGILL error in libtensorflow_framework.1.dylib #562

Open
594212 opened this issue Jun 28, 2023 · 1 comment
Open

Comments

@594212
Copy link

594212 commented Jun 28, 2023

I created an empty project, and tried to try out the library, but I ran into a problem.

Describe the bug
The gradle run task is failing with a SIGILL error in libtensorflow_framework.1.dylib. The error report suggests that the crash occurred outside the Java Virtual Machine in native code.

Steps to reproduce the behavior:
Run gradle run

Environment

- Gradle Version: 8.1.1
- Kotlin: 1.8.10
- Groovy: 3.0.15
- Ant: Apache Ant(TM) version 1.10.11
- JVM: 17.0.7 (Homebrew 17.0.7+0)
- OS: Mac OS X 13.3.1 aarch64

Log Output

> Task :app:compileKotlin UP-TO-DATE
> Task :app:compileJava NO-SOURCE
> Task :app:processResources NO-SOURCE
> Task :app:classes UP-TO-DATE
> Task :app:jar UP-TO-DATE
> Task :app:inspectClassesForKotlinIC UP-TO-DATE

> Task :app:run FAILED
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x000000013a062ba4, pid=90216, tid=16131
#
# JRE version: OpenJDK Runtime Environment (18.0.2+9) (build 18.0.2+9-61)
# Java VM: OpenJDK 64-Bit Server VM (18.0.2+9-61, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-amd64)
# Problematic frame:
# C  [libtensorflow_framework.1.dylib+0x7ba4]  tensorflow::monitoring::MetricDef<(tensorflow::monitoring::MetricKind)1, long long, 2>::MetricDef<char [11], char [7]>(absl::string_view, absl::string_view, char const (&) [11], char const (&) [7])+0x44
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/uvays.aleroev/IdeaProjects/kotlinDL/quick-start/app/hs_err_pid90216.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
4 actionable tasks: 1 executed, 3 up-to-date

build.gradle.kts

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Kotlin application project to get you started.
 * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
 * User Manual available at https://docs.gradle.org/8.1.1/userguide/building_java_projects.html
 */

plugins {
    // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
    id("org.jetbrains.kotlin.jvm") version "1.8.10"

    // Apply the application plugin to add support for building a CLI application in Java.
    application
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

configurations {
    implementation
}

val KOTLIN_DL_VERSION = "0.5.2"
dependencies {
    // Use the Kotlin JUnit 5 integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")

    // Use the JUnit 5 integration.
    testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.1")

    // This dependency is used by the application.
//    implementation("com.google.guava:guava:31.1-jre")
    // Kotlin DL
    implementation ("org.jetbrains.kotlinx:kotlin-deeplearning-api:$KOTLIN_DL_VERSION")
    implementation("org.jetbrains.kotlinx:kotlin-deeplearning-tensorflow:$KOTLIN_DL_VERSION")
    implementation("org.jetbrains.kotlinx:kotlin-deeplearning-onnx:$KOTLIN_DL_VERSION")
    implementation("org.jetbrains.kotlinx:kotlin-deeplearning-visualization:$KOTLIN_DL_VERSION")
    implementation("org.slf4j:slf4j-simple:2.0.5")

}

// Apply a specific Java toolchain to ease working on different environments.
java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(18))
    }
}

application {
    // Define the main class for the application.
    mainClass.set("quick.start.AppKt")
}

tasks.named<Test>("test") {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
}

App.kt

/*
 * This Kotlin source file was generated by the Gradle 'init' task.
 */
package quick.start

//import io.github.oshai.kotlinlogging.KotlinLogging

import mu.KotlinLogging
import org.jetbrains.kotlinx.dl.api.core.Sequential
import org.jetbrains.kotlinx.dl.api.core.layer.core.Dense
import org.jetbrains.kotlinx.dl.api.core.layer.core.Input
import org.jetbrains.kotlinx.dl.api.core.layer.reshaping.Flatten
import org.jetbrains.kotlinx.dl.api.core.loss.Losses
import org.jetbrains.kotlinx.dl.api.core.metric.Metrics
import org.jetbrains.kotlinx.dl.api.core.optimizer.Adam
import org.jetbrains.kotlinx.dl.api.summary.printSummary

private  val logger = KotlinLogging.logger {}
class App {
    val greeting: String
        get() {
            return "Hello World!"
        }
}

val model = Sequential.of(
    Input(28, 28, 1),
    Flatten(),
    Dense(300),
    Dense(100),
    Dense(10)
)


fun main() {
    logger.info { "Hello World!" }
    model.use {
        it.compile(
            optimizer = Adam(),
            loss = Losses.SOFT_MAX_CROSS_ENTROPY_WITH_LOGITS,
            metric = Metrics.ACCURACY
        )
        it.printSummary()
    }
    println(App().greeting)
}
@zaleslaw
Copy link
Collaborator

zaleslaw commented Jul 3, 2023

Thanks @594212 for the detailed description, I will try to reproduce on my MacOS station next week and answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants