...を解決するlib/include/THC/THCGeneral.h:12:18: fatal error: cuda.h:No such file or directoryエラー問題
文書ディレクトリ 1. 問題の説明 1.1構築された環境:要求通り 1.2コンパイルエラーの詳細 1.2.1 makeをコンパイルする.sh前に必要な修正 1.2.2エラーメッセージ
2.解決策 2.1私の解決方法 2.2まとめ
1.問題の説明
私はFew-shot Object Detection with Attention-RPN and Multi-Relation Detector一文のオープンソースコードをコンパイルしていますhttps://github.com/fanq15/FSOD-code時にエラーが発生しました:
pytorch0.4.1 torchvision>=0.2.0 cython matplotlib numpy scipy opencv pyyaml3.12 packaging pandas pycocotools CUDA=9.0本人は実験室の共通のワークステーションを使っているので、CUDA 9を0はusr/local/の下にインストールします(他の人が特定のバージョンのCUDAを使用することに影響しないように)、私の/homeディレクトリの下にインストールするしかありません:CUDAの一般的なインストール位置:/usr/local/cuda-9.0/私のCUDAインストール位置:/home/hongze/cudas/cuda-9.0/ 複数のCUDAをインストールした後、nvccのバージョンを必ず確認してください: バージョンが必要なバージョンでない場合は、.Bashrcファイルの変更、例えば私は2つのバージョンのCUDA: をインストールしました変更しました.bashrcファイルのこの3行は、私がどのバージョンのCUDAを有効にするかを決定します(私はソフト接続を使用していませんが、実際のディレクトリの位置を直接指しています.ソフト接続を使用する場合は、ソフト接続を変更して実装する必要があります:このブログを表示します)
1.2コンパイルエラーの詳細
1.2.1 makeをコンパイルする.sh前に必要な修正基本的にmake.shコンパイル前にCUDA_をチェックする必要があるARCHはあなたのグラフィックスカードと似合うかどうか:詳細はこのブログまたはnvidia公式サイトの情報を見てください. CUDAのソフトリンクが無効になったり、私のようにソフトリンクを使用しない場合は、CUDA_を変更する必要があります.PATH;
1.2.2エラーメッセージ
fatal error: cuda.h:No such file or directoryは全部で4回、NMSコンパイル、roi_pooling、roi_crop、roi_alignの4つの部分で発生した
2.解決方法
主に修正するのは2つの場所があります:make.shファイルの内容、makeを実行する.shのコマンド
2.1私の解決方法
この回答を参考にして
Hi all, if you encounter this error on compling fatal error: cuda.h: No such file or directory Try this: CPATH=/path/to/you/cuda/include ./make.sh
そこで私がコンパイルするときに入力したコマンドは:sh make.shをCPATH=/home/hongze/cudas/cuda 9/include/./に変更make.sh,コンパイル成功
☆また、cudaを解決しました.h見つからない問題の後に別の問題が発生しました:nms_cuda.c: No such file or directory:
FSOD-code/lib/model/nms/src/自分でファイルに参加するだけで、nms_をクリックして表示します.cuda.cファイル内容:
This aims to fix issue #17. The compling error is actually caused by missing the file nms_cuda.c. I borrow the one in Detectron.pytorch.指定された位置のnvccを強制的に使用します.https://github.com/jwyang/faster-rcnn.pytorch/issues/55 はmakeにあります.shファイルの前にこの3行を追加: は、cudaへのソフト接続を独自に作成する.hの: For me, I don’t have root access. I can’t make such symlinks to the system. So I just symlinked to the problem dir and it works now. Not recommending this, just for those in a similar situation to me with whom no environmental variable setting has helped. pytorch 0を再インストールした人がいる.4.0、そして問題を解決した Hi @huinsysu, do you solve the issue, I met the same error as yours. And I reinstall the pytorch0.4.0, then solve the issue. 誰かがmakeにいます.hでCUDA_が指定されていますARCHの値: Hope this is not too late. Actually all the solutions mentioned above does not work for me. I solved this by modifying the file ‘~/lib/make.sh’. In the file, please comment the CUDA_ARCH line and changed the ‘$CUDA_ARCH’ in each compilation into ‘-arch=arch’ Taking the nms package as an example, the previous command (line 20)is: nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH Now, we should change it as: nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -arch=sm_52 Then conduct similar operations for other packages. It should be noted that ‘arch’ is determined by your GPU type. ‘-arch=sm_52’ works for TitanX. You could look at the Compilation Section in this Page or the documents of the NVCC for information of your GPU. I am still a bit confused about the problem. I guess it results from the CUDA version. より多くの解決方法を参照してください:論文の著者の道、4つのIssueページを含んで、クリックして表示します: You can reference here to find solutions: detectron-tw, stan-dev470, stan-dev622, stan-dev561
2.2まとめ
そのことを知っているのに,その理由を知らない.
1.問題の説明
私はFew-shot Object Detection with Attention-RPN and Multi-Relation Detector一文のオープンソースコードをコンパイルしていますhttps://github.com/fanq15/FSOD-code時にエラーが発生しました:
......lib/include/THC/THCGeneral.h:12:18:fatal error: cuda.h: No such file or directory
1.1構築された環境:完全に要求通りpytorch0.4.1 torchvision>=0.2.0 cython matplotlib numpy scipy opencv pyyaml3.12 packaging pandas pycocotools CUDA=9.0
(base) hongze@lab-PowerEdge-T630 ~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176
(base) hongze@lab-PowerEdge-T630 ~/cudas$ ls
cuda-10.1 cuda9 include lib64 NVIDIA_CUDA-10.1_Samples NVIDIA_CUDA-9.0_Samples src
# .bashrc :
# cuda-9.0 cuda-10.0, source .bashrc , , nvcc , 10.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hongze/cudas/cuda-9.0/lib64
export PATH=$PATH:/home/hongze/cudas/cuda-9.0/bin
export CUDA_HOME=$CUDA_HOME:/home/hongze/cudas/cuda-9.0
1.2コンパイルエラーの詳細
1.2.1 makeをコンパイルする.sh前に必要な修正
#make.sh
#!/usr/bin/env bash
#CUDA_PATH=/usr/local/cuda/
CUDA_PATH=/home/hongze/cudas/cuda9# CUDA_PATH
export CXXFLAGS="-std=c++11"
export CFLAGS="-std=c99"
python3 setup.py build_ext --inplace
rm -rf build
# Choose cuda arch as you need
CUDA_ARCH="-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_70,code=sm_70 "# TITAN XP
# compile NMS
cd model/nms/src
echo "Compiling nms kernels by nvcc..."
nvcc -c -o nms_cuda_kernel.cu.o nms_cuda_kernel.cu \
-D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH
cd ../
python3 build.py
# compile roi_pooling
cd ../../
cd model/roi_pooling/src
echo "Compiling roi pooling kernels by nvcc..."
nvcc -c -o roi_pooling.cu.o roi_pooling_kernel.cu \
-D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH
cd ../
python3 build.py
# # compile roi_align
# cd ../../
# cd model/roi_align/src
# echo "Compiling roi align kernels by nvcc..."
# nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \
# -D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH
# cd ../
# python3 build.p
# compile roi_crop
cd ../../
cd model/roi_crop/src
echo "Compiling roi crop kernels by nvcc..."
nvcc -c -o roi_crop_cuda_kernel.cu.o roi_crop_cuda_kernel.cu \
-D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH
cd ../
python3 build.py
# compile roi_align (based on Caffe2's implementation)
cd ../../
cd modeling/roi_xfrom/roi_align/src
echo "Compiling roi align kernels by nvcc..."
nvcc -c -o roi_align_kernel.cu.o roi_align_kernel.cu \
-D GOOGLE_CUDA=1 -x cu -Xcompiler -fPIC $CUDA_ARCH
cd ../
python3 build.py
1.2.2エラーメッセージ
fatal error: cuda.h:No such file or directoryは全部で4回、NMSコンパイル、roi_pooling、roi_crop、roi_alignの4つの部分で発生した
# sh make.sh
(FSOD) hongze@lab-PowerEdge-T630 ~/Documents/FSOD-code/lib$ sh make.sh
running build_ext
building 'utils.cython_bbox' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/utils
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/numpy/core/include -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c utils/cython_bbox.c -o build/temp.linux-x86_64-3.6/utils/cython_bbox.o -Wno-cpp
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/utils
c99 build/temp.linux-x86_64-3.6/utils/cython_bbox.o -L/home/hongze/anaconda3/envs/FSOD/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/utils/cython_bbox.cpython-36m-x86_64-linux-gnu.so
building 'utils.cython_nms' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/numpy/core/include -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c utils/cython_nms.c -o build/temp.linux-x86_64-3.6/utils/cython_nms.o -Wno-cpp
gcc -pthread -shared -L/home/hongze/anaconda3/envs/FSOD/lib -Wl,-rpath=/home/hongze/anaconda3/envs/FSOD/lib,--no-as-needed -std=c99 build/temp.linux-x86_64-3.6/utils/cython_nms.o -L/home/hongze/anaconda3/envs/FSOD/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/utils/cython_nms.cpython-36m-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-3.6/utils/cython_bbox.cpython-36m-x86_64-linux-gnu.so -> utils
copying build/lib.linux-x86_64-3.6/utils/cython_nms.cpython-36m-x86_64-linux-gnu.so -> utils
Compiling nms kernels by nvcc...
Including CUDA code.
/home/hongze/Documents/FSOD-code/lib/model/nms
['/home/hongze/Documents/FSOD-code/lib/model/nms/src/nms_cuda_kernel.cu.o']
generating /tmp/tmp5qy32gtx/_nms.c
setting the current directory to '/tmp/tmp5qy32gtx'
running build_ext
building '_nms' extension
creating home
creating home/hongze
creating home/hongze/Documents
creating home/hongze/Documents/FSOD-code
creating home/hongze/Documents/FSOD-code/lib
creating home/hongze/Documents/FSOD-code/lib/model
creating home/hongze/Documents/FSOD-code/lib/model/nms
creating home/hongze/Documents/FSOD-code/lib/model/nms/src
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c _nms.c -o ./_nms.o -std=c99
In file included from /home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:4:0,
from _nms.c:570:
/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCGeneral.h:12:18: fatal error: cuda.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 51, in _build
dist.run_command('build_ext')
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "build.py", line 37, in <module>
ffi.build()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 189, in build
_build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 111, in _build_extension
outfile = ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/api.py", line 727, in compile
compiler_verbose=verbose, debug=debug, **kwds)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/recompiler.py", line 1555, in recompile
compiler_verbose, debug)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 58, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: CompileError: command 'gcc' failed with exit status 1
Compiling roi pooling kernels by nvcc...
Including CUDA code.
/home/hongze/Documents/FSOD-code/lib/model/roi_pooling
generating /tmp/tmpuhxsnvnf/_roi_pooling.c
setting the current directory to '/tmp/tmpuhxsnvnf'
running build_ext
building '_roi_pooling' extension
creating home
creating home/hongze
creating home/hongze/Documents
creating home/hongze/Documents/FSOD-code
creating home/hongze/Documents/FSOD-code/lib
creating home/hongze/Documents/FSOD-code/lib/model
creating home/hongze/Documents/FSOD-code/lib/model/roi_pooling
creating home/hongze/Documents/FSOD-code/lib/model/roi_pooling/src
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c _roi_pooling.c -o ./_roi_pooling.o -std=c99
In file included from /home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:4:0,
from _roi_pooling.c:570:
/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCGeneral.h:12:18: fatal error: cuda.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 51, in _build
dist.run_command('build_ext')
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "build.py", line 35, in <module>
ffi.build()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 189, in build
_build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 111, in _build_extension
outfile = ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/api.py", line 727, in compile
compiler_verbose=verbose, debug=debug, **kwds)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/recompiler.py", line 1555, in recompile
compiler_verbose, debug)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 58, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: CompileError: command 'gcc' failed with exit status 1
Compiling roi crop kernels by nvcc...
Including CUDA code.
/home/hongze/Documents/FSOD-code/lib/model/roi_crop
generating /tmp/tmp3j3suxnv/_roi_crop.c
setting the current directory to '/tmp/tmp3j3suxnv'
running build_ext
building '_roi_crop' extension
creating home
creating home/hongze
creating home/hongze/Documents
creating home/hongze/Documents/FSOD-code
creating home/hongze/Documents/FSOD-code/lib
creating home/hongze/Documents/FSOD-code/lib/model
creating home/hongze/Documents/FSOD-code/lib/model/roi_crop
creating home/hongze/Documents/FSOD-code/lib/model/roi_crop/src
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c _roi_crop.c -o ./_roi_crop.o -std=c99
In file included from /home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:4:0,
from _roi_crop.c:570:
/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCGeneral.h:12:18: fatal error: cuda.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 51, in _build
dist.run_command('build_ext')
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "build.py", line 36, in <module>
ffi.build()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 189, in build
_build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 111, in _build_extension
outfile = ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/api.py", line 727, in compile
compiler_verbose=verbose, debug=debug, **kwds)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/recompiler.py", line 1555, in recompile
compiler_verbose, debug)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 58, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: CompileError: command 'gcc' failed with exit status 1
Compiling roi align kernels by nvcc...
Including CUDA code.
/home/hongze/Documents/FSOD-code/lib/modeling/roi_xfrom/roi_align
generating /tmp/tmpfskoao8a/_roi_align.c
setting the current directory to '/tmp/tmpfskoao8a'
running build_ext
building '_roi_align' extension
creating home
creating home/hongze
creating home/hongze/Documents
creating home/hongze/Documents/FSOD-code
creating home/hongze/Documents/FSOD-code/lib
creating home/hongze/Documents/FSOD-code/lib/modeling
creating home/hongze/Documents/FSOD-code/lib/modeling/roi_xfrom
creating home/hongze/Documents/FSOD-code/lib/modeling/roi_xfrom/roi_align
creating home/hongze/Documents/FSOD-code/lib/modeling/roi_xfrom/roi_align/src
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c _roi_align.c -o ./_roi_align.o -std=c99
In file included from /home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:4:0,
from _roi_align.c:570:
/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCGeneral.h:12:18: fatal error: cuda.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 51, in _build
dist.run_command('build_ext')
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "build.py", line 36, in <module>
ffi.build()
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 189, in build
_build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 111, in _build_extension
outfile = ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/api.py", line 727, in compile
compiler_verbose=verbose, debug=debug, **kwds)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/recompiler.py", line 1555, in recompile
compiler_verbose, debug)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/cffi/ffiplatform.py", line 58, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: CompileError: command 'gcc' failed with exit status 1
2.解決方法
主に修正するのは2つの場所があります:make.shファイルの内容、makeを実行する.shのコマンド
2.1私の解決方法
この回答を参考にして
Hi all, if you encounter this error on compling fatal error: cuda.h: No such file or directory Try this: CPATH=/path/to/you/cuda/include ./make.sh
そこで私がコンパイルするときに入力したコマンドは:sh make.shをCPATH=/home/hongze/cudas/cuda 9/include/./に変更make.sh,コンパイル成功
#
(FSOD) hongze@lab-PowerEdge-T630 ~/Documents/FSOD-code/lib$ CPATH=/home/hongze/cudas/cuda9/include/ ./make.sh
running build_ext
building 'utils.cython_bbox' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/utils
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/numpy/core/include -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c utils/cython_bbox.c -o build/temp.linux-x86_64-3.6/utils/cython_bbox.o -Wno-cpp
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/utils
gcc -pthread -shared -L/home/hongze/anaconda3/envs/FSOD/lib -Wl,-rpath=/home/hongze/anaconda3/envs/FSOD/lib,--no-as-needed build/temp.linux-x86_64-3.6/utils/cython_bbox.o -L/home/hongze/anaconda3/envs/FSOD/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/utils/cython_bbox.cpython-36m-x86_64-linux-gnu.so
building 'utils.cython_nms' extension
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/numpy/core/include -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c utils/cython_nms.c -o build/temp.linux-x86_64-3.6/utils/cython_nms.o -Wno-cpp
utils/cython_nms.c: In function ‘__pyx_pf_5utils_10cython_nms_2soft_nms’:
utils/cython_nms.c:3399:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
__pyx_t_10 = ((__pyx_v_pos < __pyx_v_N) != 0);
^
utils/cython_nms.c:3910:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
__pyx_t_10 = ((__pyx_v_pos < __pyx_v_N) != 0);
^
gcc -pthread -shared -L/home/hongze/anaconda3/envs/FSOD/lib -Wl,-rpath=/home/hongze/anaconda3/envs/FSOD/lib,--no-as-needed build/temp.linux-x86_64-3.6/utils/cython_nms.o -L/home/hongze/anaconda3/envs/FSOD/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/utils/cython_nms.cpython-36m-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-3.6/utils/cython_bbox.cpython-36m-x86_64-linux-gnu.so -> utils
copying build/lib.linux-x86_64-3.6/utils/cython_nms.cpython-36m-x86_64-linux-gnu.so -> utils
running build_ext
building 'utils.cython_bbox' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/utils
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/numpy/core/include -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c utils/cython_bbox.c -o build/temp.linux-x86_64-3.6/utils/cython_bbox.o -Wno-cpp
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/utils
gcc -pthread -shared -L/home/hongze/anaconda3/envs/FSOD/lib -Wl,-rpath=/home/hongze/anaconda3/envs/FSOD/lib,--no-as-needed -std=c99 build/temp.linux-x86_64-3.6/utils/cython_bbox.o -L/home/hongze/anaconda3/envs/FSOD/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/utils/cython_bbox.cpython-36m-x86_64-linux-gnu.so
building 'utils.cython_nms' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/numpy/core/include -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c utils/cython_nms.c -o build/temp.linux-x86_64-3.6/utils/cython_nms.o -Wno-cpp
gcc -pthread -shared -L/home/hongze/anaconda3/envs/FSOD/lib -Wl,-rpath=/home/hongze/anaconda3/envs/FSOD/lib,--no-as-needed -std=c99 build/temp.linux-x86_64-3.6/utils/cython_nms.o -L/home/hongze/anaconda3/envs/FSOD/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/utils/cython_nms.cpython-36m-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-3.6/utils/cython_bbox.cpython-36m-x86_64-linux-gnu.so -> utils
copying build/lib.linux-x86_64-3.6/utils/cython_nms.cpython-36m-x86_64-linux-gnu.so -> utils
Compiling nms kernels by nvcc...
Including CUDA code.
/home/hongze/Documents/FSOD-code/lib/model/nms
['/home/hongze/Documents/FSOD-code/lib/model/nms/src/nms_cuda_kernel.cu.o']
generating /tmp/tmpw5rm8jqh/_nms.c
setting the current directory to '/tmp/tmpw5rm8jqh'
running build_ext
building '_nms' extension
creating home
creating home/hongze
creating home/hongze/Documents
creating home/hongze/Documents/FSOD-code
creating home/hongze/Documents/FSOD-code/lib
creating home/hongze/Documents/FSOD-code/lib/model
creating home/hongze/Documents/FSOD-code/lib/model/nms
creating home/hongze/Documents/FSOD-code/lib/model/nms/src
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c _nms.c -o ./_nms.o -std=c99
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -fPIC -DWITH_CUDA -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/hongze/anaconda3/envs/FSOD/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/hongze/anaconda3/envs/FSOD/include/python3.6m -c /home/hongze/Documents/FSOD-code/lib/model/nms/src/nms_cuda.c -o ./home/hongze/Documents/FSOD-code/lib/model/nms/src/nms_cuda.o -std=c99
gcc -pthread -shared -L/home/hongze/anaconda3/envs/FSOD/lib -Wl,-rpath=/home/hongze/anaconda3/envs/FSOD/lib,--no-as-needed -std=c99 ./_nms.o ./home/hongze/Documents/FSOD-code/lib/model/nms/src/nms_cuda.o /home/hongze/Documents/FSOD-code/lib/model/nms/src/nms_cuda_kernel.cu.o -L/home/hongze/anaconda3/envs/FSOD/lib -lpython3.6m -o ./_nms.so
☆また、cudaを解決しました.h見つからない問題の後に別の問題が発生しました:nms_cuda.c: No such file or directory:
gcc: error: /home/hongze/Documents/FSOD-code/lib/model/nms/src/nms_cuda.c: No such file or directory
FSOD-code/lib/model/nms/src/自分でファイルに参加するだけで、nms_をクリックして表示します.cuda.cファイル内容:
This aims to fix issue #17. The compling error is actually caused by missing the file nms_cuda.c. I borrow the one in Detectron.pytorch.
#export PATH=home/hongze/cudas/cuda-9.0/bin${PATH:+:${PATH}}
#export CPATH=home/hongze/cudas/cuda-9.0/include${CPATH:+:${CPATH}}
#export LD_LIBRARY_PATH=home/hongze/cudas/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
ln -s ~/cuda/include/* ~/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/
2.2まとめ
そのことを知っているのに,その理由を知らない.