Home Linux Commands How To Check If Your Linux System Supports AVX and AVX2

How To Check If Your Linux System Supports AVX and AVX2

By sk
1.9K views

In this brief tutorial, we will learn how to check if your Linux system supports AVX and AVX2 instructions from commandline. Checking for AVX/AVX2 support in your CPU is essential when dealing with software or workloads that can benefit from data parallelism and vector processing capabilities offered by these instruction set extensions. It is also a main requirement to run Large Language Models (LLMs) in your system.

What is AVX?

AVX stands for Advanced Vector Extensions. It is a set of instruction set extensions to the x86 instruction set architecture for microprocessors from Intel and AMD.

AVX provides new instructions and CPU features that allow efficient vector operations on large data sets. Specifically:

  • AVX introduces 256-bit wide vector registers and instructions that can perform parallel operations on 256-bit vectors of data, such as four 64-bit double-precision or eight 32-bit single-precision floating-point values.
  • It enhances SIMD (Single Instruction, Multiple Data) capabilities, allowing a single instruction to perform the same operation on multiple data elements simultaneously. This parallelism can provide significant performance improvements for applications that can leverage vector processing, such as multimedia, scientific computing, and machine learning workloads.
  • AVX is an extension of earlier 128-bit vector extensions like SSE (Streaming SIMD Extensions).

AVX was first introduced by Intel with the Sandy Bridge microarchitecture in 2011 and later adopted by AMD.

The AVX2 extension, introduced in 2013 with Intel's Haswell microarchitecture and AMD's Excavator microarchitecture, adds further instructions and functionality.

These vector extensions are particularly useful in workloads that involve heavy data parallelism, such as image and video processing, physics simulations, cryptography, and deep learning.

Many modern software libraries and frameworks, including those used for machine learning and AI, can take advantage of AVX and AVX2 to accelerate computations on supported hardware.

Check if your Linux machine supports AVX and AVX2

To check if your Linux machine supports AVX and AVX2 instruction sets, you can use a couple of different methods:

Check CPU Information

To determine if your Linux machine supports AVX and/or AVX2 instructions, you can check the output of the /proc/cpuinfo file or use the grep command:

$ grep -o 'avx[^ ]*' /proc/cpuinfo

This will print avx and/or avx2 (repeated for each CPU core) if your CPU supports those instruction sets.

Sample Output:

avx
avx2
avx512f
avx512dq
avx512ifma
avx512cd
avx512bw
avx512vl
avx512vbmi
avx512_vbmi2
avx512_vnni
avx512_bitalg
avx512_vpopcntdq
avx512_vp2intersect
[...]
Check if your Linux Machine Supports AVX and AVX2
Check if your Linux Machine Supports AVX and AVX2

You can also use the following grep command variants to check if your CPU supports AVX and AVX2 instructions:

$ cat /proc/cpuinfo | grep -i 'avx'

Or,

$ grep --color=always -i 'avx' /proc/cpuinfo

Here, --color=always option is used to distinguish the lines containing "avx".

Determine if your CPU Supports AVX and AVX2 Instructions in Linux
Determine if your CPU Supports AVX and AVX2 Instructions in Linux

If you see output lines containing avx and avx2, it means your CPU supports those instruction sets.

Use lscpu Utility

The lscpu utility is a great tool to get detailed information about your CPU information in Linux. It comes preinstalled with most Linux distributions.

To check if your CPU supports AVX or AVX2, run:

$ lscpu | grep avx

Look for lines mentioning AVX and AVX2 under the "Flags" section. If they are present, your CPU supports those extensions.

Sample Output:

Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 invpcid_single cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear flush_l1d arch_capabilities

Check CPU Specifications

You can also look up the specifications of your CPU model online. Most modern CPUs from Intel (since Sandy Bridge in 2011) and AMD (since Bulldozer in 2011) support AVX, and more recent generations also support AVX2.

if you're using an Intel processor, head over to the following link to verify if your Processor supports AVX:

Keep in mind that some older CPUs or low-power devices may not support AVX2, which could be a requirement for running certain LLM (Large Language Model) applications efficiently.

Related Read:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More