Unverified Commit 5e9ebe8d authored by vfdev's avatar vfdev Committed by GitHub
Browse files

Added DEBUG=1 option to build torchvision (#2603)

- can be helpful for debugging C++ extensions
parent baa592b2
import os
import io
import re
import sys
import csv
from setuptools import setup, find_packages
from pkg_resources import parse_version, get_distribution, DistributionNotFound
import subprocess
......@@ -208,6 +206,20 @@ def get_extensions():
extra_compile_args.setdefault('cxx', [])
extra_compile_args['cxx'].append('/MP')
debug_mode = os.getenv('DEBUG', '0') == '1'
if debug_mode:
print("Compile in debug mode")
extra_compile_args['cxx'].append("-g")
extra_compile_args['cxx'].append("-O0")
if "nvcc" in extra_compile_args:
# we have to remove "-OX" and "-g" flag if exists and append
nvcc_flags = extra_compile_args["nvcc"]
extra_compile_args["nvcc"] = [
f for f in nvcc_flags if not ("-O" in f or "-g" in f)
]
extra_compile_args["nvcc"].append("-O0")
extra_compile_args["nvcc"].append("-g")
sources = [os.path.join(extensions_dir, s) for s in sources]
include_dirs = [extensions_dir]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment