Undefined symbol issue

オープン
#56 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
15/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
cmake, cpp, python
領域
build-system

調査の方向性

The failure is an undefined symbol for my_grid_sampler_2d_cuda when importing the extension, so start with grid_sampler_cuda.cpp and grid_sampler_cuda_kernel.cu and check the declared function signature against the one in the error. Run nm -D on the built .so to see which symbols it exports, and compare the mangled name with the compile flags, especially -D_GLIBCXX_USE_CXX11_ABI=0. Done means the module imports cleanly, or the cause is documented. No one has replied in about six years, so expect to work this out without help.

索引モデルが issue の本文から書いたものです。

説明

Hello, I implement a custom cpp file, successfully compile it but when trying to import it via

import torch
import grid_sampler_cuda

, I encounter the following error:

ImportError: /home/shuqin/anaconda3/envs/pytorch_1.4_py3.7/lib/python3.7/site-pa
ckages/grid_sampler_cuda-0.0.0-py3.7-linux-x86_64.egg/grid_sampler_cuda.cpython-
37m-x86_64-linux-gnu.so: undefined symbol: _Z23my_grid_sampler_2d_cudaRKN2at6Ten
sorES2_b

My torch._C._GLIBCXX_USE_CXX11_ABI is False and my complier's output:

gcc -pthread -B /home/shuqin/anaconda3/envs/pytorch_1.4_py3.7/compiler_compat -W
l,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -
fPIC -I/home/shuqin/anaconda3/envs/pytorch_1.4_py3.7/lib/python3.7/site-packages
/torch/include -I/home/shuqin/anaconda3/envs/pytorch_1.4_py3.7/lib/python3.7/sit
e-packages/torch/include/torch/csrc/api/include -I/home/shuqin/anaconda3/envs/py
torch_1.4_py3.7/lib/python3.7/site-packages/torch/include/TH -I/home/shuqin/anac
onda3/envs/pytorch_1.4_py3.7/lib/python3.7/site-packages/torch/include/THC -I/us
r/local/cuda-10.0/include -I/home/shuqin/anaconda3/envs/pytorch_1.4_py3.7/includ
e/python3.7m -c grid_sampler_cuda.cpp -o build/temp.linux-x86_64-3.7/grid_sample
r_cuda.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=grid_sampler_cud
a -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 
cc1plus: warning: command line option '-Wstrict-prototypes'  is valid for C/ObjC
but not for C++
/usr/local/cuda-10.0/bin/nvcc -I/home/shuqin/anaconda3/envs/pytorch_1.4_py3.7/li
b/python3.7/site-packages/torch/include -I/home/shuqin/anaconda3/envs/pytorch_1.
4_py3.7/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home
/shuqin/anaconda3/envs/pytorch_1.4_py3.7/lib/python3.7/site-packages/torch/inclu
de/TH -I/home/shuqin/anaconda3/envs/pytorch_1.4_py3.7/lib/python3.7/site-package
s/torch/include/THC -I/usr/local/cuda-10.0/include -I/home/shuqin/anaconda3/envs
/pytorch_1.4_py3.7/include/python3.7m -c grid_sampler_cuda_kernel.cu -o build/te
mp.linux-x86_64-3.7/grid_sampler_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__
CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexp
r --compiler-options '-fPIC' -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_N
AME=grid_sampler_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=s
m_75 -std=c++11

I browse some relative issues and many of them suggest adding -D_GLIBCXX_USE_CXX11_ABI=0 to compiler, however this is already satisfied in my case. My pytorch version is 1.4.0, installed via conda install pytorch torchvision cudatoolkit=10.0 -c pytorch. After installing pytorch, I might have upgrade my gcc version to 7.5.0, and install horovod which also install a gxx_linux-64 via conda install gxx_linux-64`.

Could somenbody please help me on this?

主要言語
Python
スター
1.2k
フォーク
250
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pytorch/extension-cpp のほかの issue

pytorch/extension-cpp の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。