Add --no-gpu flag

pull/1464/head
Piero Toffanin 2022-05-30 15:52:13 -04:00
rodzic d62ca21243
commit ed425d2465
4 zmienionych plików z 15 dodań i 7 usunięć

Wyświetl plik

@ -270,6 +270,12 @@ def config(argv=None, parser=None):
'resizes images when necessary, resulting in faster processing and '
'lower memory usage. Since GSD is an estimate, sometimes ignoring it can result in slightly better image output quality. Default: %(default)s')
parser.add_argument('--no-gpu',
action=StoreTrue,
nargs=0,
default=False,
help='Do not use GPU acceleration, even if it\'s available. Default: %(default)s')
parser.add_argument('--mesh-size',
metavar='<positive integer>',
action=StoreValue,

Wyświetl plik

@ -5,7 +5,7 @@ import ctypes
from opendm import log
from repoze.lru import lru_cache
def gpu_disabled_by_user():
def gpu_disabled_by_user_env():
return bool(os.environ.get('ODM_NO_GPU'))
@lru_cache(maxsize=None)
@ -68,11 +68,13 @@ def get_cuda_compute_version(device_id = 0):
return (compute_major.value, compute_minor.value)
@lru_cache(maxsize=None)
def has_gpu():
if gpu_disabled_by_user():
def has_gpu(args):
if gpu_disabled_by_user_env():
log.ODM_INFO("Disabling GPU features (ODM_NO_GPU is set)")
return False
if args.no_gpu:
log.ODM_INFO("Disabling GPU features (--no-gpu is set)")
return False
if sys.platform == 'win32':
nvcuda_path = os.path.join(os.environ.get('SYSTEMROOT'), 'system32', 'nvcuda.dll')

Wyświetl plik

@ -251,7 +251,7 @@ class OSFMContext:
config.append("matcher_type: %s" % osfm_matchers[matcher_type])
# GPU acceleration?
if has_gpu():
if has_gpu(args):
max_photo = find_largest_photo(photos)
w, h = max_photo.width, max_photo.height
if w > h:

Wyświetl plik

@ -76,7 +76,7 @@ class ODMOpenMVSStage(types.ODM_Stage):
gpu_config = []
if not has_gpu():
if not has_gpu(args):
gpu_config.append("--cuda-device -2")
if args.pc_tile: