Optimize TensorFlow: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
No edit summary
(Fix: remove --- horizontal lines (7 removed))
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Optimizing target CPU flags ==
{{Status
|status=Draft
|owner=Knowledge Agent
|last_update=2026-07-16
|review=Pending
}}
 
{{TOC}}
 
== Overview ==
 
Optimize TensorFlow에 대한 기술 문서입니다.
 
=== Summary ===
 
* 무엇인가? - Optimize TensorFlow
* 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
* 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시
 
 
== Purpose ==
 
이 문서가 존재하는 이유
 
* Goal: Optimize TensorFlow에 대한 기술 정보 제공
* Scope: Optimize TensorFlow의 개념, 사용법, 설정
* Non-goals: 다른 주제로의 확장
 
 
== Key Concepts ==
 
{| class="wikitable"
! Concept
! Description
! Related
|-
| Optimize TensorFlow
| HPC/서버 환경에서 중요한 기술 개념
| [[Linux]], [[Server]]
|}
 
 
== Detailed Explanation ==
 
Optimize TensorFlow to [[CPU features]] by turning on all the computation [[optimization]] opportunities provided by the CPU.  
Optimize TensorFlow to [[CPU features]] by turning on all the computation [[optimization]] opportunities provided by the CPU.  
== Compiler optimization flags ==
Do you wondering how much of a difference those instructions end up making on your machine between genera pip packages and custom optimization on the system?
Do you wondering how much of a difference those instructions end up making on your machine between genera pip packages and custom optimization on the system?
Because pre-built pip packages do not enable all machine capable [[CPU features|optimization flags]] in it or may not perfectly set for your machine, for example, GCC compiler optimization flgags like
Because pre-built pip packages do not enable all machine capable [[CPU features|optimization flags]] in it or may not perfectly set for your machine, for example, GCC compiler optimization flgags like
<code>gcc -O<number></code> (O the letter, not the number).
<code>gcc -O<number></code> (O the letter, not the number).
* -O0: Turns off optimization entirely. Fast compile times, good for debugging.  This is the default if you don't specify any which you probably don't want.
* -O0: Turns off optimization entirely. Fast compile times, good for debugging.  This is the default if you don't specify any which you probably don't want.
* -O1: Basic optimization level.
* -O1: Basic optimization level.
Line 14: Line 52:
* -O3: Highest optimization possible. Also vectorizes loops, can use all AVX  registers.
* -O3: Highest optimization possible. Also vectorizes loops, can use all AVX  registers.
* -Os: Small size. Basically enables -O2 options which do not increase size.  Can be useful for machines that have limited storage and/or CPUs with small  cache sizes.
* -Os: Small size. Basically enables -O2 options which do not increase size.  Can be useful for machines that have limited storage and/or CPUs with small  cache sizes.
If you are building TensorFlow on the same machine that will be running it you can just use <code>-O3 -march=native</code>. If you are building on a different machine, you can use the command below to see which flags GCC would set and then pass them when configuring TF.
If you are building TensorFlow on the same machine that will be running it you can just use <code>-O3 -march=native</code>. If you are building on a different machine, you can use the command below to see which flags GCC would set and then pass them when configuring TF.
  # This is the output on my machine:
  # This is the output on my machine:
  $ gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
  $ gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
Line 27: Line 63:
  -mno-prefetchwt1 -mclflushopt -mxsavec -mxsaves -mno-avx512dq -mno-avx512bw
  -mno-prefetchwt1 -mclflushopt -mxsavec -mxsaves -mno-avx512dq -mno-avx512bw
  -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps
  -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps
-mno-avx5124vnniw -mno-clwb -mmwaitx -mclzero -mno-pku -mno-rdpid --param
 
l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=512
 
-mtune=znver1
== Best Practices ==
 
* 최신 버전 사용 권장
* 공식 문서 참고
* 테스트 환경에서 먼저 검증
 


== References ==
== References ==
<references />
 
* [https://wiki.hpcmate.com Optimize TensorFlow]
 
 
== Related Pages ==
 
* [[Linux]]
* [[Server]]
* [[Hardware]]
* [[Network]]
 
 
[[Category:Server]]
== Knowledge Graph ==
 
Related
 
→ [[Linux]]
→ [[Server]]
→ [[Hardware]]
→ [[Network]]
 
[[Category:Reference]]

Latest revision as of 11:30, 17 July 2026

Template:Status

Template:TOC

Overview

Optimize TensorFlow에 대한 기술 문서입니다.

Summary

  • 무엇인가? - Optimize TensorFlow
  • 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
  • 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시


Purpose

이 문서가 존재하는 이유

  • Goal: Optimize TensorFlow에 대한 기술 정보 제공
  • Scope: Optimize TensorFlow의 개념, 사용법, 설정
  • Non-goals: 다른 주제로의 확장


Key Concepts

Concept Description Related
Optimize TensorFlow HPC/서버 환경에서 중요한 기술 개념 Linux, Server


Detailed Explanation

Optimize TensorFlow to CPU features by turning on all the computation optimization opportunities provided by the CPU. Do you wondering how much of a difference those instructions end up making on your machine between genera pip packages and custom optimization on the system? Because pre-built pip packages do not enable all machine capable optimization flags in it or may not perfectly set for your machine, for example, GCC compiler optimization flgags like gcc -O<number> (O the letter, not the number).

  • -O0: Turns off optimization entirely. Fast compile times, good for debugging. This is the default if you don't specify any which you probably don't want.
  • -O1: Basic optimization level.
  • -O2: Recommended for most things. SSE / AVX may be used, but not fully.
  • -O3: Highest optimization possible. Also vectorizes loops, can use all AVX registers.
  • -Os: Small size. Basically enables -O2 options which do not increase size. Can be useful for machines that have limited storage and/or CPUs with small cache sizes.

If you are building TensorFlow on the same machine that will be running it you can just use -O3 -march=native. If you are building on a different machine, you can use the command below to see which flags GCC would set and then pass them when configuring TF.

# This is the output on my machine:
$ gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
/usr/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/cc1 -E -quiet -v - -march=znver1
-mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -msse4a -mcx16 -msahf -mmovbe
-maes -msha -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi
-mno-sgx -mbmi2 -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mno-rtm
-mno-hle -mrdrnd -mf16c -mfsgsbase -mrdseed -mprfchw -madx -mfxsr -mxsave
-mxsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf
-mno-prefetchwt1 -mclflushopt -mxsavec -mxsaves -mno-avx512dq -mno-avx512bw
-mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps


Best Practices

  • 최신 버전 사용 권장
  • 공식 문서 참고
  • 테스트 환경에서 먼저 검증


References


Related Pages

Knowledge Graph

Related

LinuxServerHardwareNetwork