srvk / eesen

The official repository of the Eesen project
http://arxiv.org/abs/1507.08240
Apache License 2.0
824 stars 342 forks source link

Fix gpucompute compilation in CUDA 9 and in GCC 6+ #163

Closed JulianSlzr closed 6 years ago

JulianSlzr commented 6 years ago

When compiling EESEN on CUDA 9, one gets the following error in src/gpucompute/Makefile:

nvcc fatal : Unsupported gpu architecture 'compute_20'

since Compute Capability 2.x was removed in CUDA 9; see https://github.com/kaldi-asr/kaldi/issues/1918. This PR backports Kaldi's solution (https://github.com/kaldi-asr/kaldi/pull/1919).

Then, once nvcc and GCC 6+ are invoked, failure to use constexpr in src/gpucompute/ctc-utils.h is no longer tolerated, giving errors:

...
ctc-utils.h:57:54: error: ‘constexpr’ needed for in-class initialization of static data member ‘const double NumericLimits<double>::max_’ of non-integral type [-fpermissive]_
   static const double max_ = 1.7976931348623157e+308;
                                                      ^
# --error 0x1 --
Makefile:86: recipe for target 'cuda-kernels.o' failed
make[1]: *** [cuda-kernels.o] Error 1

Unconditionally using constexpr fixes this, but breaks nvcc and GCC 5:

#$ cudafe --allow_managed --m64 --gnu_version=50400 -tused --no_remove_unneeded_entities  --gen_c_file_name "/tmp/tmpxft_00001f4d_00000000-4_cuda-kernels.compute_20.cudafe1.c" --stub_file_name "/tmp/tmpxft_00001f4d_00000000-4_cuda-kernels.compute_20.cudafe1.stub.c" --gen_device_file_name "/tmp/tmpxft_00001f4d_00000000-4_cuda-kernels.compute_20.cudafe1.gpu" --nv_arch "compute_20" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_00001f4d_00000000-3_cuda-kernels.module_id" --include_file_name "tmpxft_00001f4d_00000000-2_cuda-kernels.fatbin.c" "/tmp/tmpxft_00001f4d_00000000-19_cuda-kernels.compute_20.cpp1.ii" 
ctc-utils.h(36): error: explicit type is missing ("int" assumed)

ctc-utils.h(36): error: expected a ";"

ctc-utils.h(37): error: explicit type is missing ("int" assumed)

ctc-utils.h(37): error: "constexpr" has already been declared in the current scope

...
70 errors detected in the compilation of "/tmp/tmpxft_00001f4d_00000000-19_cuda-kernels.compute_20.cpp1.ii".
# --error 0x2 --
Makefile:86: recipe for target 'cuda-kernels.o' failed

Hence, this PR also passes -std=c++11 to NVCC so that it tells GCC 5 to recognize the constexpr keyword as well.

I have tested the resulting PR on (x86-64):