Could it be used with PyTorch=1.6.0 in anaconda?
LeungWaiHo opened this issue · comments
Questions like headings. I just want to use this to replace tf.image.crop_and_resize() in order to change code from tensorflow to pytorch.
Thank you for your answer!
When I input python setup.py install in anaconda, error occurs:
running install
running bdist_egg
running egg_info
writing roi_align.egg-info/PKG-INFO
writing dependency_links to roi_align.egg-info/dependency_links.txt
writing requirements to roi_align.egg-info/requires.txt
writing top-level names to roi_align.egg-info/top_level.txt
reading manifest file 'roi_align.egg-info/SOURCES.txt'
writing manifest file 'roi_align.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'roi_align.crop_and_resize_cpu' extension
Emitting ninja build file /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
g++ -pthread -shared -B /home/lab318/anaconda3/compiler_compat -L/home/lab318/anaconda3/lib -Wl,-rpath=/home/lab318/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/crop_and_resize.o -L/home/lab318/anaconda3/lib/python3.8/site-packages/torch/lib -lc10 -ltorch -ltorch_cpu -ltorch_python -o build/lib.linux-x86_64-3.8/roi_align/crop_and_resize_cpu.cpython-38-x86_64-linux-gnu.so
building 'roi_align.crop_and_resize_gpu' extension
Emitting ninja build file /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/2] :/usr/local/cuda-11.0/bin/nvcc -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/TH -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/THC -I:/usr/local/cuda-11.0/include -I/home/lab318/anaconda3/include/python3.8 -c -c /home/lab318/RoIAlign.pytorch/roi_align/src/cuda/crop_and_resize_kernel.cu -o /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/cuda/crop_and_resize_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=crop_and_resize_gpu -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 -std=c++14
FAILED: /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/cuda/crop_and_resize_kernel.o
:/usr/local/cuda-11.0/bin/nvcc -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/TH -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/THC -I:/usr/local/cuda-11.0/include -I/home/lab318/anaconda3/include/python3.8 -c -c /home/lab318/RoIAlign.pytorch/roi_align/src/cuda/crop_and_resize_kernel.cu -o /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/cuda/crop_and_resize_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=crop_and_resize_gpu -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 -std=c++14
/bin/sh: 1: :/usr/local/cuda-11.0/bin/nvcc: not found
[2/2] c++ -MMD -MF /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/crop_and_resize_gpu.o.d -pthread -B /home/lab318/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/TH -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/THC -I:/usr/local/cuda-11.0/include -I/home/lab318/anaconda3/include/python3.8 -c -c /home/lab318/RoIAlign.pytorch/roi_align/src/crop_and_resize_gpu.cpp -o /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/crop_and_resize_gpu.o -g -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=crop_and_resize_gpu -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
FAILED: /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/crop_and_resize_gpu.o
c++ -MMD -MF /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/crop_and_resize_gpu.o.d -pthread -B /home/lab318/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/TH -I/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/THC -I:/usr/local/cuda-11.0/include -I/home/lab318/anaconda3/include/python3.8 -c -c /home/lab318/RoIAlign.pytorch/roi_align/src/crop_and_resize_gpu.cpp -o /home/lab318/RoIAlign.pytorch/build/temp.linux-x86_64-3.8/roi_align/src/crop_and_resize_gpu.o -g -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=crop_and_resize_gpu -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/lab318/RoIAlign.pytorch/roi_align/src/crop_and_resize_gpu.cpp:2:0:
/home/lab318/anaconda3/lib/python3.8/site-packages/torch/include/ATen/cuda/CUDAContext.h:5:30: fatal error: cuda_runtime_api.h: 没有那个文件或目录
compilation terminated.
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/home/lab318/anaconda3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1509, in _run_ninja_build
subprocess.run(
File "/home/lab318/anaconda3/lib/python3.8/subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "setup.py", line 24, in
setup(
File "/home/lab318/anaconda3/lib/python3.8/site-packages/setuptools/init.py", line 165, in setup
return distutils.core.setup(**attrs)
File "/home/lab318/anaconda3/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/lab318/anaconda3/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/lab318/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/lab318/anaconda3/lib/python3.8/site-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/home/lab318/anaconda3/lib/python3.8/site-packages/setuptools/command/install.py", line 109, in do_egg_install
self.run_command('bdist_egg')
File "/home/lab318/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/lab318/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/lab318/anaconda3/lib/python3.8/site-packages/setuptools/command/bdist_egg.py", line 174, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "/home/lab318/anaconda3/lib/python3.8/site-packages/setuptools/command/bdist_egg.py", line 160, in call_command
self.run_command(cmdname)
File "/home/lab318/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/lab318/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/lab318/anaconda3/lib/python3.8/site-packages/setuptools/command/install_lib.py", line 11, in run
self.build()
File "/home/lab318/anaconda3/lib/python3.8/distutils/command/install_lib.py", line 107, in build
self.run_command('build_ext')
File "/home/lab318/anaconda3/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/lab318/anaconda3/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/lab318/anaconda3/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 87, in run
_build_ext.run(self)
File "/home/lab318/anaconda3/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/home/lab318/anaconda3/lib/python3.8/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/home/lab318/anaconda3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 649, in build_extensions
build_ext.build_extensions(self)
File "/home/lab318/anaconda3/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "/home/lab318/anaconda3/lib/python3.8/distutils/command/build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "/home/lab318/anaconda3/lib/python3.8/distutils/command/build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "/home/lab318/anaconda3/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
_build_ext.build_extension(self, ext)
File "/home/lab318/anaconda3/lib/python3.8/distutils/command/build_ext.py", line 528, in build_extension
objects = self.compiler.compile(sources,
File "/home/lab318/anaconda3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 469, in unix_wrap_ninja_compile
_write_ninja_file_and_compile_objects(
File "/home/lab318/anaconda3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1228, in _write_ninja_file_and_compile_objects
_run_ninja_build(
File "/home/lab318/anaconda3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1529, in _run_ninja_build
raise RuntimeError(message)
RuntimeError: Error compiling objects for extension
Solved this question by:
--First-- modify setup.py by:
add:
"
import os
include_dirs = [os.path.realpath('../include'), 'usr/local/cuda/include/']
"
add in CUDAExtension
"
include_dirs = include_dirs,
"
--Then-- export CUDA_HOME="/usr/local/cuda/