Fix for AVX2 support in Visual Studio#13525
Conversation
|
Can one of the admins verify this patch? |
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
I signed it! |
|
CLAs look good, thanks! |
|
Also note that AVX and AVX2 are not enabled by default in CMakeLists.txt, even when native arch optimization is enabled. I will place another pull request to fix this in the future, along with a number of other CMake fixes. |
|
Jenkins, test this please. |
|
Jenkins, test this please. |
|
Looks like the CI server is having some unrelated failures? Is that common? |
|
Unfortunately more common than we would like. |
|
The change looks good to me, but I'll defer to @benoitsteiner since it's in Eigen code. (I'm not sure how or whether we pull in Eigen code from other repositories, and whether it would be better to make the change upstream first.) |
|
@scottmudge, thanks for your job about avx2, great! but it still hints when running, What else should I do to enable AVX2 for tensorflow on WINDOWS? Thanks so much. Frank |
|
Hey Frank, Yes the CMakeLists.txt file in TensorFlow needs some modifications; it does not properly set the AVX/AVX2 flags. Find this line in the CMakeLists.txt file in ./tensorflow/contrib/cmake/: And change it to: Sort of a hacky way to force enable it, but it'll do the job for now. I need to do another pull request with a better fix. If you get error C1001 when compiling with GPU support, take a look at this thread: I'm not sure if it does it on the master branch, but I had the problem as of v1.3.1 |
|
I tried your hacky way, but it still indicated the issue of “was not compiled to use: AVX2”. I noticed the information in configuration stage on my platform, I got the code from tensorflow:master with the latest commit as follow, Finally I modified one line in CMakeLists.txt with adding "/arch:AVX2", and it seems to work. Haha, it is another hacky way. if (tensorflow_WIN_CPU_SIMD_OPTIONS) Thanks so much for your help. |
|
@yang0773 |
|
@iNomaD Here is one I compiled, v1.3.1 w/ AVX2, GPU (up to CUDA 6.1), x64 for Windows: |
|
Actually tf on windows can be built like this: The last option can be: =/arch:AVX2, then log "Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2" is disappeared. |
|
can you build it using AVX2 and AVX at the same time? |
|
https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros In Visual C++, when you set |
Summary: Fix missing functions for MSVC 2015 Inspired by tensorflow/tensorflow#13525 Closes #9023 Reviewed By: soumith Differential Revision: D8694046 Pulled By: ezyang fbshipit-source-id: 92cb7b9efd76d97a264c12a1521be550176f58d5
Summary: Fix missing functions for MSVC 2015 Inspired by tensorflow/tensorflow#13525 Closes pytorch/pytorch#9023 Reviewed By: soumith Differential Revision: D8694046 Pulled By: ezyang fbshipit-source-id: 92cb7b9efd76d97a264c12a1521be550176f58d5
Summary: Fix missing functions for MSVC 2015 Inspired by tensorflow/tensorflow#13525 Closes pytorch/pytorch#9023 Reviewed By: soumith Differential Revision: D8694046 Pulled By: ezyang fbshipit-source-id: 92cb7b9efd76d97a264c12a1521be550176f58d5
Summary: Fix missing functions for MSVC 2015 Inspired by tensorflow/tensorflow#13525 Closes pytorch#9023 Reviewed By: soumith Differential Revision: D8694046 Pulled By: ezyang fbshipit-source-id: 92cb7b9efd76d97a264c12a1521be550176f58d5
This is a fix for issue #10199. Visual Studio 2015 (possibly other versions) lacks definitions for _mm256_extract_epi8, -16, -32, or -64 in the immintrin.h header, nor in the associated runtime, so it must be implemented manually.
For wider portability these functions are renamed based on their required extraction indices. These intrinsics should be just as fast as the externally linked versions provided by GCC.