From 1dee8b8ec3400f7997929e53f5583121779fd610 Mon Sep 17 00:00:00 2001 From: AlexDBlack Date: Wed, 11 Sep 2019 16:50:49 +1000 Subject: [PATCH 1/2] Add CPU/AVX page Signed-off-by: AlexDBlack --- cpu.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 cpu.md diff --git a/cpu.md b/cpu.md new file mode 100644 index 000000000..ec3020af7 --- /dev/null +++ b/cpu.md @@ -0,0 +1,84 @@ +--- +title: CPU and AVX +short_title: CPU +description: CPU and AVX support in ND4J/Deeplearning4j +layout: default +redirect_from: "/cpu" +--- + + +### What is AVX, and why does it matter? + +AVX (Advanced Vector Extensions) is a set of CPU instructions for accelerating numerical computations. +AVX only applies to nd4j-native (CPU) backend for x86 devices, not GPUs and not ARM/PPC devices. + +Why AVX matters: performance. + +You want to use the highest level of AVX supported by your system. + +AVX support - summary: +* Most modern x86 CPUs: AVX2 is supported +* Some high-end server CPUs: AVX512 may be supported +* Old CPUs (pre 2012) and low power x86 (Atom, Celeron): No AVX support (usually) + +AVX is backward compatible, so it's possible run a generic x86 or AVX2 binary on a system supporting AVX512. + +Note on current snapshots (and in future releases, after 1.0.0-beta5) you may get a warning as follows, if AVX is not configured optimally: +``` +o.n.l.c.n.CpuNDArrayFactory - *********************************** CPU Feature Check Warning *********************************** +o.n.l.c.n.CpuNDArrayFactory - Warning: Initializing ND4J with Generic x86 binary on a CPU with AVX/AVX2 support +o.n.l.c.n.CpuNDArrayFactory - Using ND4J with AVX/AVX2 will improve performance. See deeplearning4j.org/cpu for more details +o.n.l.c.n.CpuNDArrayFactory - Or set environment variable ND4J_IGNORE_AVX=true to suppress this warning +o.n.l.c.n.CpuNDArrayFactory - ************************************************************************************************ +``` + + +### Configuring AVX in ND4J/DL4J + +Defaults: +* 1.0.0-beta5 and earlier: "generic x86" (no AVX) is the default for nd4j/nd4j-platform dependencies +* Current snapshots and later versions of ND4J: AVX2 is the default + + +To configure AVX2 and AVX512, you need to specify a classifier for the appropriate architecture. + +The following binaries are provided for x86 architectures: +* Generic x86 (no AVX): `linux-x86_64`, `windows-x86_64`, `macosx-x86_64` +* AVX2: `linux-x86_64-avx2`, `windows-x86_64-avx2`, `macosx-x86_64-avx2` +* AVX512: `linux-x86_64-avx512` + + +Example: AVX2 on Windows (Maven pom.xml) +``` + + org.nd4j + nd4j-native + ${nd4j.version} + + + + org.nd4j + nd4j-native + ${nd4j.version} + windows-x86_64-avx2 + +``` + + +Example: AVX512 on Linux (Maven pom.xml) +``` + + org.nd4j + nd4j-native + ${nd4j.version} + + + + org.nd4j + nd4j-native + ${nd4j.version} + linux-x86_64-avx512 + +``` + +Note that you need *both* dependencies - with and without the classifier. \ No newline at end of file From a15a791a43bf7d44b5bb63084a598430b8c61493 Mon Sep 17 00:00:00 2001 From: AlexDBlack Date: Wed, 11 Sep 2019 17:00:54 +1000 Subject: [PATCH 2/2] Tweaks Signed-off-by: AlexDBlack --- cpu.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/cpu.md b/cpu.md index ec3020af7..1c8923f60 100644 --- a/cpu.md +++ b/cpu.md @@ -6,22 +6,24 @@ layout: default redirect_from: "/cpu" --- +# ND4J - CPU (nd4j-native) AVX Configuration ### What is AVX, and why does it matter? -AVX (Advanced Vector Extensions) is a set of CPU instructions for accelerating numerical computations. -AVX only applies to nd4j-native (CPU) backend for x86 devices, not GPUs and not ARM/PPC devices. +AVX (Advanced Vector Extensions) is a set of CPU instructions for accelerating numerical computations. See [Wikipedia](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) for more details. -Why AVX matters: performance. +Note that AVX only applies to nd4j-native (CPU) backend for x86 devices, not GPUs and not ARM/PPC devices. -You want to use the highest level of AVX supported by your system. +Why AVX matters: performance. You want to use the version of ND4J compiled with the highest level of AVX supported by your system. -AVX support - summary: + +AVX support for different CPUs - summary: * Most modern x86 CPUs: AVX2 is supported * Some high-end server CPUs: AVX512 may be supported * Old CPUs (pre 2012) and low power x86 (Atom, Celeron): No AVX support (usually) -AVX is backward compatible, so it's possible run a generic x86 or AVX2 binary on a system supporting AVX512. +AVX is backward compatible, so for example it's possible run a generic x86 or AVX2 binary on a system supporting AVX512. +However it is not possible to run Note on current snapshots (and in future releases, after 1.0.0-beta5) you may get a warning as follows, if AVX is not configured optimally: ``` @@ -35,20 +37,22 @@ o.n.l.c.n.CpuNDArrayFactory - ************************************************** ### Configuring AVX in ND4J/DL4J -Defaults: +As noted earlier, for best performance you should use the version of ND4J that matches your CPU's supported AVX level. + +ND4J defaults configuration (when just including the nd4j-native or nd4j-native-platform dependencies without maven classifier configuration): * 1.0.0-beta5 and earlier: "generic x86" (no AVX) is the default for nd4j/nd4j-platform dependencies * Current snapshots and later versions of ND4J: AVX2 is the default To configure AVX2 and AVX512, you need to specify a classifier for the appropriate architecture. -The following binaries are provided for x86 architectures: +The following binaries (nd4j-native classifiers) are provided for x86 architectures: * Generic x86 (no AVX): `linux-x86_64`, `windows-x86_64`, `macosx-x86_64` * AVX2: `linux-x86_64-avx2`, `windows-x86_64-avx2`, `macosx-x86_64-avx2` * AVX512: `linux-x86_64-avx512` -Example: AVX2 on Windows (Maven pom.xml) +**Example: Configuring AVX2 on Windows (Maven pom.xml)** ``` org.nd4j @@ -65,7 +69,7 @@ Example: AVX2 on Windows (Maven pom.xml) ``` -Example: AVX512 on Linux (Maven pom.xml) +**Example: Configuring AVX512 on Linux (Maven pom.xml)** ``` org.nd4j @@ -81,4 +85,4 @@ Example: AVX512 on Linux (Maven pom.xml) ``` -Note that you need *both* dependencies - with and without the classifier. \ No newline at end of file +Note that you need *both* nd4j-native dependencies - with and without the classifier. \ No newline at end of file