{Moving the issue from GitHub to here. Please find the original post here}
Issue Description
I am trying to use .npy files in my Kotlin code, but when I try to load it with this code (as given in tests and example codes):
import org.nd4j.linalg.factory.Nd4j
import org.nd4j.linalg.indexing.NDArrayIndex
import org.nd4j.linalg.io.ClassPathResource
import java.io.File
fun main() {
val homePath = System.getProperty("user.dir")
println("Working Directory = $homePath")
val fileName = "src/assets/Feedback.npy"
val file = File("/$homePath/$fileName")
println("File size = " + file.length())
val validFile = ClassPathResource("/$homePath/$fileName").file
println(validFile)
}
I am getting this error:
Working Directory = /Users/vidhey/coding/Kotlin/intellij-sandbox
File size = 11691
Exception in thread "main" java.io.FileNotFoundException: class path resource [Users/vidhey/coding/Kotlin/intellij-sandbox/src/assets/Feedback.npy] cannot be resolved to URL because it does not exist
at org.nd4j.linalg.io.ClassPathResource.getURL(ClassPathResource.java:269)
at org.nd4j.linalg.io.AbstractResource.getURI(AbstractResource.java:57)
at TestKt.main(Test.kt:14)
at TestKt.main(Test.kt)
Process finished with exit code 1
I am not sure if I’m using the code wrong or if this is some bug.
Though I noticed one thing: the path starts with “Users/vidhey/…” instead of how it should on an absolute path “/Users/vidhey/…”, even though I set the right working directory and passed the proper path.
Version Information
- ND4J-native 1.0.0-beta6
- macOS Catalina on MacBook Air 2015
- Working on IntelliJ IDEA 2020.2.2 Ultimate
I tried using beta7 and beta6 both with the ClassPathResource and with the File object.
With the ClassPathResource, I’m getting the error I showed above. With the File object, the app crashes with some kind of segmentation fault:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000012eaf7614, pid=3819, tid=0x0000000000000c03
#
# JRE version: Java(TM) SE Runtime Environment (8.0_162-b12) (build 1.8.0_162-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.162-b12 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C [libnd4jcpu.dylib+0x32614] lengthForShapeBufferPointer+0x4
#
# Core dump written. Default location: /cores/core or core.3819
#
# An error report file with more information is saved as:
# /Users/vidhey/coding/Kotlin/intellij-sandbox/hs_err_pid3819.log
#
# If you would like to submit a bug report, please visit:
# http://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.
#
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
I have posted the entire core dump log on the issue I referenced above if you want to check it out.
I have been using the same files in Python without any issue, so the files are not corrupted. But I am setting pickle=True
in Python when making these files since these are quite big files. Can that be the issue?