This error happens because in init.cc (lines 193-197) there is a check if AVX is supported:
#ifdef __AVX__
if (!platform::MayIUse(platform::avx)) {
AVX_GUIDE(AVX, NonAVX);
}
#endif
And platform::MayIUse()
function has 2 implementations depending on PADDLE_WITH_XBYAK flag (cpu_info.cc lines 106-145):
#ifdef PADDLE_WITH_XBYAK
static Xbyak::util::Cpu cpu;
bool MayIUse(const cpu_isa_t cpu_isa) {
...
}
#else
bool MayIUse(const cpu_isa_t cpu_isa) {
...
}
#endif
Xbyak is used here to determine if CPU has specific instruction set (AVX, AVX2, AVX512F ...). Implementation without XBYAK is as follows:
bool MayIUse(const cpu_isa_t cpu_isa) {
if (cpu_isa == isa_any) {
return true;
} else {
return false;
}
}
So it returns false every time except for MayIUse(platform::isa_any).
This is why building paddle without XBYAK makes init.cc crash on !platform::MayIUse(platform::avx)
condition and building without AVX "fixes" problem because #ifdef __AVX__
is omitted.
I'm not sure what is expected behavior of such scenario so please comment on that.
I'm not sure what is expected behavior of such scenario so please comment on that.
We think that all the following 4 scenarios should work successfully.
WITH_XBYAK=ON, WITH_AVX=ON
WITH_XBYAK=OFF, WITH_AVX=ON
WITH_XBYAK=ON, WITH_AVX=OFF
: Does this exist? I.eWITH_XBYAK=ON
must depend onWITH_AVX=ON
?WITH_XBYAK=OFF, WITH_AVX=OFF
Main problem here is that without XBYAK we can't check if avx instructions are available during runtime. Many algorithm implementations rely on MayIUse()
function which returns always false
if program has been built without XBYAK. This will lead to not executing AVX versions of many algorithms. I still don't know what is the expected outcome of such configuration (WITH_XBYAK=OFF, WITH_AVX=ON
)? Should it just don't crash and pretend everything is ok (as I mentioned, all implementations checking for avx flags will be disabled due to lack of xbyak)? In my opinion these 2 flags should be correlated (either ON-ON or OFF-OFF) because I can't see the point of compiling with AVX but without XBYAK or the other way around.
In my opinion, these 2 flags should be correlated (either ON-ON or OFF-OFF)
XBYAK is a JIT assembler for x86(IA-32)/x64(AMD64, x86-64) MMX/SSE/SSE2/SSE3/SSSE3/SSE4/FPU/AVX/AVX2/AVX-512 by C++ header, thus, it supports NO_AVX as well.
But (either ON-ON or OFF-OFF) may be a temporary solution.
#22716 should fix this issue for every case that was mentioned. If you could, please confirm that on your machines.
I test above four cases, this issue have been fixed. But I have another issue #22757, please help to see it.
问题描述
docker编译:镜像 hub.baidubce.com/paddlepaddle/paddle:latest-gpu-cuda9.0-cudnn7-dev