haifengl / smile

Statistical Machine Intelligence & Learning Engine
https://haifengl.github.io
Other
6.02k stars 1.13k forks source link

Subdivide smile-mkl #641

Closed robertvazan closed 3 years ago

robertvazan commented 3 years ago

Depending on smile-mkl is convenient, but it blows my app's JAR to 900MB and stretches build to several minutes. It would be nice to have platform-specific versions of the smile-mkl dependency that would be equally convenient to use.

haifengl commented 3 years ago

You can use exclude clause to filter out jars/platforms you don't need.

robertvazan commented 3 years ago

Sadly, Maven doesn't allow classifiers in exclusions. The closest workaround I found is below, but this still throws an exception when I try to run it. No idea why.

        <dependency>
            <groupId>com.github.haifengl</groupId>
            <artifactId>smile-mkl</artifactId>
            <version>2.6.0</version>
            <exclusions>
                <exclusion>
                    <!-- Exclude all native libraries by default. -->
                    <groupId>org.bytedeco</groupId>
                    <artifactId>mkl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Explicitly include platform-specific libraries only. -->
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>mkl</artifactId>
            <version>2020.3-1.5.4</version>
            <classifier>linux-x86_64</classifier>
        </dependency>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>mkl</artifactId>
            <version>2020.3-1.5.4</version>
            <classifier>linux-x86_64-redist</classifier>
        </dependency>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>mkl</artifactId>
            <version>2020.3-1.5.4</version>
            <classifier>linux-x86</classifier>
        </dependency>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>mkl</artifactId>
            <version>2020.3-1.5.4</version>
            <classifier>linux-x86-redist</classifier>
        </dependency>
robertvazan commented 3 years ago

I found the last missing dependency. The configuration below works. Still, it was hard to get right. It would be much easier if I could just specify classifier on smile-mkl and it would pull in what's needed.

        <dependency>
            <!-- Native libraries needed by smile-math. -->
            <groupId>com.github.haifengl</groupId>
            <artifactId>smile-mkl</artifactId>
            <version>2.6.0</version>
            <exclusions>
                <exclusion>
                    <!-- Exclude all native libraries by default. -->
                    <groupId>org.bytedeco</groupId>
                    <artifactId>mkl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Explicitly include platform-specific libraries only. -->
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>mkl</artifactId>
            <version>2020.3-1.5.4</version>
        </dependency>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>mkl</artifactId>
            <version>2020.3-1.5.4</version>
            <classifier>linux-x86_64</classifier>
        </dependency>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>mkl</artifactId>
            <version>2020.3-1.5.4</version>
            <classifier>linux-x86_64-redist</classifier>
        </dependency>
haifengl commented 3 years ago

Thanks for sharing.