spconv の概要、環境構成とインストール、および発生したさまざまなエラー レポートの処理

spconv の概要、環境構成とインストール、および発生したさまざまなエラー レポートの処理

このブログでは、spconv の紹介、spconv 1.x および spconv2.x のインストール方法、および発生したさまざまなエラー レポートの処理について説明します。詳細については、公式 GitHub リンクを参照してください。

spconv の概要

spconv は空間スパース畳み込みライブラリであり、高度に最適化されたスパース畳み込み実装と tensor コアのサポートを提供するプロジェクトです。spconv は、多数のゼロ要素を含むスパース データを効率的に処理するように設計されており、主に 3D 点群の畳み込み演算に使用されます。

spconv のインストール

ブロガー自身のハードウェア構成は次のとおりです。

  • Linux (Ubuntu 20.04)
  • NVIDIA GeForce 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++.solibstdc++.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

次の 2 つのエラーは、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 ~/.bashrc、CUDA 関連の環境変数を設定します。

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