spconv 소개, 환경 구성 및 설치, 발생한 다양한 오류 보고서 처리

spconv 소개, 환경 구성 및 설치, 발생한 다양한 오류 보고서 처리

이번 블로그에서는 spconv에 대해 소개하고, spconv 1.x와 spconv2.x 설치 방법, 다양한 오류 리포트 처리 방법에 대해 설명하겠습니다.자세한 내용은 공식 GitHub 링크를 참고해주세요.

spconv 소개

spconv는 고도로 최적화된 희소 컨볼루션 구현 및 텐서 코어 지원을 제공하는 프로젝트인 공간 희소 컨볼루션 라이브러리입니다. spconv는 많은 수의 0 요소를 포함하는 희소 데이터를 효율적으로 처리하도록 설계되었으며 주로 3D 포인트 클라우드의 컨볼루션 작업에 사용됩니다.

spconv 설치

블로거의 자체 하드웨어 구성은 다음과 같습니다.

  • 리눅스(우분투 20.04)
  • 엔비디아 지포스 RTX 3090
  • NVIDIA 그래픽 카드 드라이버 버전: 12.0
  • CUDA 버전: 11.3

먼저 pytorch, cuda 및 기타 관련 소프트웨어 패키지를 설치하십시오.

conda create --name env_name python=3.7 cmake=3.22.1
conda install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit=11.3 -c pytorch -c conda-forge
conda install cudnn -c conda-forge
conda install boost

bashrc 파일을 열고: vim ~/.bashrc환경 변수를 설정합니다.

export PATH=/usr/local/cuda/bin:$PATH
export CUDA_HOME=/usr/local/cuda/bin:$CUDA_HOME
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/[$YourUserName]/anaconda3/envs/[$YourEnvName]/include
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/[$YourUserName]/anaconda3/envs/[$YourEnvName]/include
export LIBRARY_PATH=$LIBRARY_PATH:/[$YourUserName]/anaconda3/envs/[$YourEnvName]/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/[$YourUserName]/anaconda3/envs/[$YourEnvName]/lib

소스 코드에서 spconv 1.x 설치

spconv 1.x는 공식적으로 폐기되어 유지 관리되지 않으므로 spconv 2.x를 사용하는 것이 좋습니다. 또한 spconv 2.x는 spconv 1.x에 비해 최적화되어 속도와 효율성이 향상되었습니다. 버전 요구 사항으로 인해 spconv 1.x를 설치해야 하는 경우 소스 코드를 컴파일하고 설치해야 합니다.
다음은 spconv 1.2.1을 설치하는 공식 단계입니다.

# STEP 1: get source code
git clone https://github.com/traveller59/spconv.git 
cd spconv
git checkout v1.2.1
git submodule update --init --recursive 

# STEP 2: compile
python setup.py bdist_wheel

# STEP 3: install
cd ./dist
pip install spconv-1.2.1-cp37-cp37m-linux_x86_64.whl

# check if is successfully installed
python 
import spconv

pip 설치 spconv 2.x

spconv 2.x는 현재 pip install을 통한 설치를 지원하며, 사용자 환경에 따라 다음 명령을 실행하도록 선택할 수 있습니다.

# 预先安装cumm和timm
pip install cumm timm
# cpu
pip install spconv
# cuda 10.2
pip install spconv-cu102
# cuda 11.3
pip install spconv-cu113
# cuda 11.4
pip install spconv-cu114
# cuda 11.6
pip install spconv-cu116
# cuda 11.7
pip install spconv-cu117
# cuda 11.8
pip install spconv-cu118
# cuda 12.0
pip install spconv-cu120

오류 처리

여기에서는 주로 spconv 1.x 설치 시 발생하는 오류와 해결 방법을 나열합니다.

오류 1

error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

gcc 버전 4.8.5를 입력합니다 gcc --version. 해결 방법은 gcc 5.4.0 버전을 설치하는 것입니다. 여기서는 conda 가상 환경 설치를 사용하고 있습니다.

conda install https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2

이 패키지의 함정은 miniconda3/envs/env_name/lib파일 아래의 소프트 libstdc++.so링크가 동적 링크 라이브러리를 libstdc++.so.6가리키고 libstdc++.so.6.0.21이 소프트 링크가 환경의 원래 소프트 링크를 덮어쓴다는 것입니다. 미래.도서관.

이로 인해 pytorch 버전이 더 높으면 libstdc++.so.6.0.21버전이 오래되었기 때문에 오류가 보고됩니다.

ImportError: /xxx/miniconda3/envs/env_name/lib/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /xxx/miniconda3/envs/env_name/lib/python3.7/site-packages/open3d/open3d.cpython-37m-x86_64-linux-gnu.so)

해결책은 miniconda3/envs/env_name/lib소프트 링크를 입력한 다음 동일한 디렉터리에 있는 동적 링크 라이브러리의 상위 버전(예: libstdc++.so) 으로 연결하는 것입니다 . 명령은 다음과 같습니다.libstdc++.so.6libstdc++.so.6.0.32

# 先删除原来的软连接
rm libstdc++.so
rm libstdc++.so.6
# 建立新的软连接
ln -s libstdc++.so.6.0.32 libstdc++.so
ln -s libstdc++.so.6.0.32 libstdc++.so.6

참조링크: https://blog.csdn.net/j___t/article/details/107308883

오류 2

/xxx/spconv/include/tensorview/tensorview.h:741:23: error: template declaration of ‘constexpr const char* const tv::type_s’
 constexpr const char *type_s = detail::TypeToString<T>::value;
                       ^
/xxx/spconv/include/tensorview/tensorview.h: In member function ‘std::string tv::TensorView<T, Rank, PtrTraits, Tindex>::repr(Os&) const’:
/xxx/spconv/include/tensorview/tensorview.h:1124:26: error: ‘type_s’ was not declared in this scope
       ss << "Tensor[" << type_s<T> << "]" << std::endl;
                          ^
/xxx/spconv/include/tensorview/tensorview.h:1124:34: error: expected primary-expression before ‘>’ token
       ss << "Tensor[" << type_s<T> << "]" << std::endl;
                                  ^
/xxx/spconv/include/tensorview/tensorview.h:1124:36: error: expected primary-expression before ‘<<’ token
       ss << "Tensor[" << type_s<T> << "]" << std::endl;
                                    ^
/xxx/spconv/include/tensorview/tensorview.h:1135:24: error: ‘type_s’ was not declared in this scope
     ss << "Tensor[" << type_s<T> << "]: shape=" << shape()
                        ^
/xxx/spconv/include/tensorview/tensorview.h:1135:32: error: expected primary-expression before ‘>’ token
     ss << "Tensor[" << type_s<T> << "]: shape=" << shape()
                                ^
/xxx/spconv/include/tensorview/tensorview.h:1135:34: error: expected primary-expression before ‘<<’ token
     ss << "Tensor[" << type_s<T> << "]: shape=" << shape()
                                  ^
/xxx/spconv/include/tensorview/tensorview.h: At global scope:
/xxx/spconv/include/tensorview/tensorview.h:1270:23: error: template declaration of ‘constexpr const char* const tv::detail::type_printf_format_v’
 constexpr const char *type_printf_format_v = TypePrintfFormat<T>::value;
                       ^
/xxx/spconv/include/tensorview/tensorview.h: In function ‘void tv::printTensorView(tv::TensorView<T, Rank, PtrTraits, Tindex>)’:
/xxx/spconv/include/tensorview/tensorview.h:1343:34: error: ‘type_printf_format_v’ is not a member of ‘tv::detail’
   return printTensorView(tensor, detail::type_printf_format_v<Traw>);
                                  ^
/xxx/spconv/include/tensorview/tensorview.h:1343:67: error: expected primary-expression before ‘>’ token
   return printTensorView(tensor, detail::type_printf_format_v<Traw>);
                                                                   ^
/xxx/spconv/include/tensorview/tensorview.h:1343:68: error: expected primary-expression before ‘)’ token
   return printTensorView(tensor, detail::type_printf_format_v<Traw>);
                                                                    ^
/xxx/spconv/include/tensorview/tensorview.h: In function ‘void tv::printTensorView(const T*, tv::Shape)’:
/xxx/spconv/include/tensorview/tensorview.h:1349:26: error: ‘type_printf_format_v’ is not a member of ‘tv::detail’
                          detail::type_printf_format_v<Traw>);
                          ^
/xxx/spconv/include/tensorview/tensorview.h:1349:59: error: expected primary-expression before ‘>’ token
                          detail::type_printf_format_v<Traw>);
                                                           ^
/xxx/spconv/include/tensorview/tensorview.h:1349:60: error: expected primary-expression before ‘)’ token
                          detail::type_printf_format_v<Traw>);

해결방법은 빌드폴더를 직접 삭제하고 다시 실행해보시면 python setup.py bdist_wheel해결되지 않으면 Boost/.를 spconv/include/에 복사해보시면 되지만 이 방법은 시도해보지 않아서 가능한지 잘 모르겠습니다. 해결되었습니다.

오류 3

다음 두 가지 오류는 CUDA 환경 변수를 찾을 수 없거나 올바르지 않기 때문에 발생합니다.

CMake Error at /disk1/zhuhe/miniconda3/envs/env_name/lib/python3.7/site-packages/cmake/data/share/cmake-3.28/Modules/CMakeDetermineCUDACompiler.cmake:270 (message):
  Failed to detect a default CUDA architecture.



  Compiler output:

Call Stack (most recent call first):
  CMakeLists.txt:9 (project)
CMake Error at /xxx/miniconda3/envs/env_name/lib/python3.7/site-packages/torch/share/cmake/Caffe2/public/cuda.cmake:87 (message):
  FindCUDA says CUDA version is (usually determined by nvcc), but the CUDA
  headers say the version is ERROR: ld.so: object

  10.2.  This often occurs when you set both CUDA_HOME and
  CUDA_NVCC_EXECUTABLE to non-standard locations, without also setting PATH
  to point to the correct nvcc.  Perhaps, try re-running this command again
  with PATH=/usr/local/cuda-10.2/bin:$PATH.  See above log messages for more
  diagnostics, and see https://github.com/pytorch/pytorch/issues/8092 for
  more details.
Call Stack (most recent call first):
  /xxx/miniconda3/envs/env_name/lib/python3.7/site-packages/torch/share/cmake/Caffe2/Caffe2Config.cmake:88 (include)
  /xxx/miniconda3/envs/env_name/lib/python3.7/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
  CMakeLists.txt:22 (find_package)

bashrc 파일을 열고 vim ~/.bashrcCUDA 관련 환경 변수를 설정합니다.

export PATH=/usr/local/cuda/bin:$PATH
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

추천

출처blog.csdn.net/weixin_43603658/article/details/135089416