Closed GOATmessi8 closed 7 years ago
The gpu support is still missing, by add cuda I mean grid generation support cuda now. Will add soon. Hang tight.
Take a look at https://github.com/fxia22/stn.pytorch/pull/2.
I guess it might be one of possible ways to support gpu.
Best,
Jae Hyun
@lim0606 Thank you so much!
@fxia22 @lim0606 thanks for your work.
I'm trying to use the new cuda version but when i execute build.py i get the following error:
Including CUDA code.
/home/jj0/Downloads/stn.pytorch-master/script
generating /tmp/tmp118_y402/_my_lib.c
running build_ext
building '_my_lib' extension
creating home
creating home/jj0
creating home/jj0/Downloads
creating home/jj0/Downloads/stn.pytorch-master
creating home/jj0/Downloads/stn.pytorch-master/script
creating home/jj0/Downloads/stn.pytorch-master/script/src
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/jj0/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/jj0/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/jj0/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/home/jj0/anaconda3/include/python3.6m -c _my_lib.c -o ./_my_lib.o
In file included from /home/jj0/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:4:0,
from _my_lib.c:434:
/home/jj0/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCGeneral.h:9:18: fatal error: cuda.h: No such file or directory
#include "cuda.h"
^
compilation terminated.
Traceback (most recent call last):
File "/home/jj0/anaconda3/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/home/jj0/anaconda3/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/home/jj0/anaconda3/lib/python3.6/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/home/jj0/anaconda3/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/jj0/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 58, in _build
dist.run_command('build_ext')
File "/home/jj0/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/jj0/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/home/jj0/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "/home/jj0/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "/home/jj0/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/home/jj0/anaconda3/lib/python3.6/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/jj0/anaconda3/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/jj0/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 164, in build
_build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
File "/home/jj0/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 100, in _build_extension
ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
File "/home/jj0/anaconda3/lib/python3.6/site-packages/cffi/api.py", line 672, in compile
compiler_verbose=verbose, debug=debug, **kwds)
File "/home/jj0/anaconda3/lib/python3.6/site-packages/cffi/recompiler.py", line 1475, in recompile
compiler_verbose, debug)
File "/home/jj0/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 29, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/home/jj0/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 65, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.ffiplatform.VerificationError: CompileError: command 'gcc' failed with exit status 1
It seems the problem is that it can't find cuda.h, but i correctly installed it and i already used it with the other pytorch modules without any problems.
Should i modify the path somewhere to specify my cuda.h location?
@jj0mst CUDA support is not fully integrated yet. Are you using make.sh
? You need to make sure the environment path CUDA_PATH
is set correctly.
I solved it with a full reinstallation of cuda. Now the build is fine.
I proposed a change to stn.py that worked for me to run the module with cuda.
Warning: i had to manually modify the following line in make.sh:
nvcc -c -o my_lib_cuda_kernel.cu.o my_lib_cuda_kernel.cu -x cu -Xcompiler -fPIC -arch=sm_52
You have to specify in -arch the compute capability of your gpu (in my case i used -arch=sm_30 since i have gtx 850 with compute capability of 3.0) or the network will try to use ops that are not supported on your gpu.
If someone knows how, just change it to detect it automatically.
@lim0606 @jj0mst I tested the cuda version, it is 6x-10x faster than CPU version. Good job guys! Let me know if there are any further problems.
@jj0mst one workaround solution for not finding 'cuda.h' would be
CPATH=/usr/local/cuda-8.0/include ./make.sh
Does it support GPU now? I saw a commit says add cuda