Skip to content

Instantly share code, notes, and snippets.

@Moddus
Created February 12, 2016 12:18
Show Gist options
  • Save Moddus/8be506c1278e611a808d to your computer and use it in GitHub Desktop.
Save Moddus/8be506c1278e611a808d to your computer and use it in GitHub Desktop.
deeplearning4j load openblas
public class BlasWrapper extends BaseBlasWrapper {
private static final Logger log = LoggerFactory.getLogger(BlasWrapper.class);
public final static String FORCE_NATIVE = "org.nd4j.linalg.cpu.force_native";
static {
// System property toggle hasSetNative var
// if the property isn't set the warning is allways displayed.
String forceNative = System.getProperty(FORCE_NATIVE,"false");
boolean hasSetNative = false;
if(Boolean.parseBoolean(forceNative)) {
try {
Field blasInstance = BLAS.class.getDeclaredField("INSTANCE");
BLAS newInstance = (BLAS) Class.forName("com.github.fommil.netlib.NativeSystemBLAS").newInstance();
setFinalStatic(blasInstance, newInstance);
hasSetNative = true;
} catch(ClassNotFoundException e) {
log.warn("Native BLAS not available on classpath");
} catch (Exception e) {
log.warn("unable to force native BLAS", e);
}
}
//Check that native system blas is used:
if(!hasSetNative){
System.out.println("****************************************************************");
System.out.println("WARNING: COULD NOT LOAD NATIVE SYSTEM BLAS");
System.out.println("ND4J performance WILL be reduced");
System.out.println("Please install native BLAS library such as OpenBLAS or IntelMKL");
System.out.println("See http://nd4j.org/getstarted.html#open for further details");
System.out.println("****************************************************************");
}
}
****************************************************************
WARNING: COULD NOT LOAD NATIVE SYSTEM BLAS
ND4J performance WILL be reduced
Please install native BLAS library such as OpenBLAS or IntelMKL
See http://nd4j.org/getstarted.html#open for further details
****************************************************************
Starting training
12:05:19,774 WARN ~ Objective function automatically set to minimize. Set stepFunction in neural net configuration to change default settings.
Feb 12, 2016 12:05:19 PM com.github.fommil.jni.JniLoader liberalLoad
INFORMATION: successfully loaded /tmp/jniloader920291678166987460netlib-native_system-linux-x86_64.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment