Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile with GCC 11 due to missing limits header #467

Closed
Shin-Ogata opened this issue May 9, 2023 · 1 comment · Fixed by #468
Closed

Cannot compile with GCC 11 due to missing limits header #467

Shin-Ogata opened this issue May 9, 2023 · 1 comment · Fixed by #468

Comments

@Shin-Ogata
Copy link
Member

Thank you for great jobs.
When I tried to build on Ubuntu 22.04 with GCC 11 environment, I encountered the problem that I could not compile because the <limits> header was not found.

Condition

  • nnabla v1.35.1 setup
cd ~/opt
wget https://github.com/sony/nnabla/archive/v1.35.1.tar.gz
tar xvfz v1.35.1.tar.gz
rm v1.35.1.tar.gz

cd nnabla-1.35.1
mkdir -p build && cd build
cmake .. -DBUILD_CPP_UTILS=ON -DBUILD_PYTHON_PACKAGE=OFF -DNNABLA_UTILS_WITH_HDF5=ON
make
sudo make install
  • nnabla-ext-cuda v1.35.0 setup
cd ~/opt
wget https://github.com/sony/nnabla-ext-cuda/archive/v1.35.0.tar.gz -O ext-v1.35.0.tar.gz
tar xvfz ext-v1.35.0.tar.gz
rm ext-v1.35.0.tar.gz

cd nnabla-ext-cuda-1.35.0
pip3 install -U -r python/requirements.txt
mkdir build && cd build
cmake -DNNABLA_DIR=../../nnabla-1.35.1 -DCPPLIB_LIBRARY=../../nnabla-1.35.1/build/lib/libnnabla.so ..
make # ← encounterd this problem

Error Message

ubuntu@DESKTOP-FU0HHQF:~/opt/nnabla-ext-cuda-1.35.0_NG/build$ make
[  0%] Building NVCC (Device) object src/nbla/cuda/CMakeFiles/cuda_compile_1.dir/utils/cuda_compile_1_generated_scan_setup.cu.o
/home/ubuntu/opt/nnabla-ext-cuda-1.35.0_NG/src/nbla/cuda/utils/scan_setup.cu(52): error: namespace "std" has no member "numeric_limits"
    if (size_input > std::numeric_limits<int32_t>::max()) {
                          ^

/home/ubuntu/opt/nnabla-ext-cuda-1.35.0_NG/src/nbla/cuda/utils/scan_setup.cu(52): error: type name is not allowed
    if (size_input > std::numeric_limits<int32_t>::max()) {
                                         ^

/home/ubuntu/opt/nnabla-ext-cuda-1.35.0_NG/src/nbla/cuda/utils/scan_setup.cu(52): error: no instance of overloaded function "max" matches the argument list
    if (size_input > std::numeric_limits<int32_t>::max()) {
                                                 ^

3 errors detected in the compilation of "/home/ubuntu/opt/nnabla-ext-cuda-1.35.0_NG/src/nbla/cuda/utils/scan_setup.cu".
CMake Error at cuda_compile_1_generated_scan_setup.cu.o.Release.cmake:280 (message):
  Error generating file
  /home/ubuntu/opt/nnabla-ext-cuda-1.35.0_NG/build/src/nbla/cuda/CMakeFiles/cuda_compile_1.dir/utils/./cuda_compile_1_generated_scan_setup.cu.o


make[2]: *** [src/nbla/cuda/CMakeFiles/nnabla_cuda.dir/build.make:1792: src/nbla/cuda/CMakeFiles/cuda_compile_1.dir/utils/cuda_compile_1_generated_scan_setup.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:143: src/nbla/cuda/CMakeFiles/nnabla_cuda.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Cause of the problem

In GCC 11 environment, it seems that std::numeric_limits cannot be resolved in scan_setup.cu with existing header includes, and <limits> needs to be added explicitly.
The following changes have little impact, and I think they are valid in environments other than GCC 11.
I confirmed that it can be built only with this fix.

  • src/nbla/cuda/utils/scan_setup.cu
+ #include <limits>
#include <nbla/cuda/utils/scan_setup.hpp>

Thanks.


OS: WSL2 Ubuntu 22.04
GCC: v11.3.0

CUDA: v12.1.1
cuDNN: v8.9.1

@TomonobuTsujikawa
Copy link
Contributor

Thank you for creating this issue and preparing PR, we will review it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants