[환경구축] CUDA 및 PyTorch 환경에서의 GCC 버전 불일치로 인한 컴파일 오류

JB·2024년 1월 23일
0
post-custom-banner

컴퓨터 환경
OS : Ubuntu22 LTS (64-bit)
HW(CPU/GPU) : Intel Core i9-9980XE / NVIDIA GeForce GTX 1080 Ti
CUDA : 11.4


DROID-SLAM 을 설치하는 도중 컴파일 오류가 발생함.


[1/3] /usr/local/cuda-11.4/bin/nvcc -I/home/username/droid-slam/thirdparty/eigen -I/home/username/anaconda3/envs/droid_env/lib/python3.7/site-packages/torch/include -I/home/username/anaconda3/envs/droid_env/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/username/anaconda3/envs/droid_env/lib/python3.7/site-packages/torch/include/TH -I/home/username/anaconda3/envs/droid_env/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-11.4/include -I/home/username/anaconda3/envs/droid_env/include/python3.7m -c -c /home/username/droid-slam/src/correlation_kernels.cu -o /home/username/droid-slam/build/temp.linux-x86_64-cpython-37/src/correlation_kernels.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_86,code=sm_86 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="gcc"' '-DPYBIND11_STDLIB="libstdcpp"' '-DPYBIND11_BUILD_ABI="cxxabi1011"' -DTORCH_EXTENSION_NAME=droid_backends -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
FAILED: /home/username/droid-slam/build/temp.linux-x86_64-cpython-37/src/correlation_kernels.o
/usr/local/cuda-11.4/bin/nvcc -I/home/username/droid-slam/thirdparty/eigen -I/home/username/anaconda3/envs/droid_env/lib/python3.7/site-packages/torch/include -I/home/username/anaconda3/envs/droid_env/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/username/anaconda3/envs/droid_env/lib/python3.7/site-packages/torch/include/TH -I/home/username/anaconda3/envs/droid_env/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-11.4/include -I/home/username/anaconda3/envs/droid_env/include/python3.7m -c -c /home/username/droid-slam/src/correlation_kernels.cu -o /home/username/droid-slam/build/temp.linux-x86_64-cpython-37/src/correlation_kernels.o -D__CUDA_NO_HALF_OPERATORS -D__CUDA_NO_HALF_CONVERSIONS_ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_86,code=sm_86 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=droid_backends -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
/usr/include/stdio.h(189): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(201): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(223): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(260): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(285): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(294): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(303): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(309): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(315): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(830): error: attribute "malloc" does not take arguments

/usr/include/stdlib.h(566): error: attribute "malloc" does not take arguments

/usr/include/stdlib.h(570): error: attribute "malloc" does not take arguments

/usr/include/stdlib.h(799): error: attribute "malloc" does not take arguments

/usr/include/wchar.h(155): error: attribute "malloc" does not take arguments

/usr/include/wchar.h(582): error: attribute "malloc" does not take arguments

15 errors detected in the compilation of "/home/username/droid-slam/src/correlation_kernels.cu".

-> 결론은 "malloc 이렇게 쓰면 안됨" 인데 다른 연구원 선배님 컴퓨터(18.04) 에서는 잘 돌아가길래 gcc 버전만 7. 으로 낮춰주었다.

해결방법:

  1. 현재 GCC 버전 확인:

    gcc --version

    현재 시스템에서 사용 중인 GCC 버전을 확인합니다.

  2. GCC 버전 다운그레이드:

    호환되는 GCC 버전을 설치하기 위해 GCC를 다운그레이드합니다. GCC 7 버전으로 다운그레이드하는 경우. 뒤에 붙는 숫자는 priority.

    sudo apt-get install gcc-7 g++-7
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 700
  3. gcc 설정 확인 및 버전 확인

    sudo update-alternatives --config gcc
    gcc --version # 바뀌면 된거다!
  1. 프로젝트 재설치:
    변경된 환경에서 프로젝트를 다시 설치합니다.

    python setup.py install
profile
자율주행 이동체를 배우고 있는 JB입니다.
post-custom-banner

0개의 댓글