提交 6439d81b authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #3895 from nouiz/debug

[DOC, ENH] allow to use gdb with nvcc. Doc how to use gdb
......@@ -983,6 +983,27 @@ macros defined by ``COp``. Finally, the function
macros and also because it calls ``vector_elemwise_mult()`` which is
an apply-specific function.
Using GDB to debug Op's C code
==============================
When debugging C code, it can be useful to use GDB for code compiled
by Theano.
For this, you must enable this Theano: `cmodule.remove_gxx_opt=True`.
For the GPU, you must add in this second flag `nvcc.flags=-g` (it slow
down computation on the GPU, but it is enabled by default on the CPU).
Then you must start Python inside GDB and in it start your Python
process (e.g. theano-nose):
.. code-block::
$gdb python
(gdb)r bin/theano-nose theano/
`Quick guide to GDB <https://www.cs.cmu.edu/~gilpin/tutorial/>`_.
Final Note
==========
......
......@@ -194,15 +194,16 @@ if compile_cuda_ndarray and cuda_available:
tmpdir = os.environ['TMPDIR']
if not os.path.exists(tmpdir):
os.makedirs(tmpdir)
compiler = nvcc_compiler.NVCC_compiler()
preargs = ['-O3'] + compiler.compile_args()
preargs += [f for f in config.nvcc.flags.split(' ') if f]
compiler.compile_str(
'cuda_ndarray',
code,
location=cuda_ndarray_loc,
include_dirs=[cuda_path],
libs=[config.cublas.lib],
preargs=['-O3'] + compiler.compile_args(),
preargs=preargs,
)
from cuda_ndarray.cuda_ndarray import *
except Exception as e:
......
......@@ -203,6 +203,9 @@ class NVCC_compiler(Compiler):
preargs = list(preargs)
if sys.platform != 'win32':
preargs.append('-fPIC')
if config.cmodule.remove_gxx_opt:
preargs = [p for p in preargs if not p.startswith('-O')]
cuda_root = config.cuda.root
# The include dirs gived by the user should have precedence over
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论