Tensorflow custom op build - jinwooklim/my-exp GitHub Wiki

Tensorflow custom op build

์ฐธ์กฐ :

http://litaotju.github.io/c++/2019/02/24/Why-we-need-D_GLIBCXX_USE_CXX11_ABI=0/

https://nuggy875.tistory.com/63

https://medium.com/@patrickorcl/compile-with-nvcc-3566fbdfdbf

1. "-D_GLIBCXX_USE_CXX11_ABI=0" flag.

The official TensorFlow packages are built with GCC 4 and use the older ABI. For GCC 5 and later, make your build compatible with the older ABI using: โ€“cxxopt=โ€-D_GLIBCXX_USE_CXX11_ABI=0โ€. ABI compatibility ensures that custom ops built against the official TensorFlow package continue to work with the GCC 5 built package

ABI (Application Binary Interface) ๋Š” OS, library์˜ machine code level interface ์ด๋‹ค.

ABI๋Š” program component ๊ฐ„์˜ interface ๋กœ์„œ, A program component ์—์„œ B program component ๋กœ binary format information์ด ์ „๋‹ฌ๋˜๋Š” ๊ฒƒ or system call์— response ํ•˜๋Š” ๊ฒƒ์„ ๊ฒฐ์ •ํ•œ๋‹ค.

( ABI ๋Š” API ์™€ ์œ ์‚ฌํ•˜์ง€๋งŒ, API๋Š” source code level์ด๊ณ  ABI๋Š” program component ๊ฐ„์˜ interface ์ด๋‹ค. )

์ฆ‰, tensorflow custom op ๋ฅผ build ํ•˜๋Š”๋ฐ "-D_GLIBCXX_USE_CXX11_ABI=0" flag๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ๋Š”, GCC version 5 ์ด์ƒ์˜ code์— ํ˜ธํ™˜์„ฑ์„ ์œ„ํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

2. Error: no kernel image is available for execution on the device

์ด์™€ ๊ฐ™์€ Error๋Š” GPU architecture๋ฅผ ์ •์˜ํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ๋‹ฌ๋ผ์„œ ๊ทธ๋ ‡๋‹ค. ๋”ฐ๋ผ์„œ, make.sh ์—์„œ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’๋“ค์„ GPU arch ์— ๋งž์ถ”์–ด์„œ ๋ณ€๊ฒฝํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

In Example.

RTX2080 : compute_75, sm_75

GTX1080 : compute_61, sm_61

Titan Xp : compute_61, sm_61