FenTechSolutions / CausalDiscoveryToolbox

Package for causal inference in graphs and in the pairwise settings. Tools for graph structure recovery and dependencies are included.
https://fentechsolutions.github.io/CausalDiscoveryToolbox/html/index.html
MIT License
1.12k stars 197 forks source link

[BUG] Importing cdt without CUDA throws FileNotFoundError for nvidia-smi #68

Closed petergtz closed 4 years ago

petergtz commented 4 years ago

Describe the bug When importing cdt on a Linux machine without CUDA it throws the exception FileNotFoundError: [Errno 2] No such file or directory: 'nvidia-smi': 'nvidia-smi'.

Full stack trace:

_ ERROR collecting test/causal_tools/causal_discovery/third_party_support/test_cdt.py _
/path/to/python/lib/python3.6/site-packages/cdt/utils/Settings.py:152: in autoset_settings
    devices = ast.literal_eval(os.environ["CUDA_VISIBLE_DEVICES"])
/path/to/python/python3.6/lib/python3.6/os.py:669: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CUDA_VISIBLE_DEVICES'

During handling of the above exception, another exception occurred:
test/causal_tools/causal_discovery/third_party_support/test_cdt.py:7: in <module>
    from causality.causal_tools.causal_discovery.third_party_support.cdt import orient_causal_edges_via_pairwise_methods
/path/to/python/lib/python3.6/site-packages/causality/causal_tools/causal_discovery/third_party_support/cdt.py:6: in <module>
    import cdt
/path/to/python/lib/python3.6/site-packages/cdt/__init__.py:28: in <module>
    import cdt.causality
/path/to/python/lib/python3.6/site-packages/cdt/causality/__init__.py:24: in <module>
    from .pairwise import __init__
/path/to/python/lib/python3.6/site-packages/cdt/causality/pairwise/__init__.py:24: in <module>
    from .ANM import ANM
/path/to/python/lib/python3.6/site-packages/cdt/causality/pairwise/ANM.py:31: in <module>
    from .model import PairwiseModel
/path/to/python/lib/python3.6/site-packages/cdt/causality/pairwise/model.py:31: in <module>
    from ...utils.Settings import SETTINGS
/path/to/python/lib/python3.6/site-packages/cdt/utils/__init__.py:34: in <module>
    from .loss import (TTestCriterion,
/path/to/python/lib/python3.6/site-packages/cdt/utils/loss.py:25: in <module>
    from .Settings import SETTINGS
/path/to/python/lib/python3.6/site-packages/cdt/utils/Settings.py:184: in <module>
    SETTINGS = ConfigSettings()
/path/to/python/lib/python3.6/site-packages/cdt/utils/Settings.py:92: in __init__
    self = autoset_settings(self)
/path/to/python/lib/python3.6/site-packages/cdt/utils/Settings.py:164: in autoset_settings
    includeNan=False))
/path/to/python/lib/python3.6/site-packages/GPUtil/GPUtil.py:123: in getAvailable
    GPUs = getGPUs()
/path/to/python/lib/python3.6/site-packages/GPUtil/GPUtil.py:64: in getGPUs
    p = Popen(["nvidia-smi","--query-gpu=index,uuid,utilization.gpu,memory.total,memory.used,memory.free,driver_version,name,gpu_serial,display_active,display_mode", "--format=csv,noheader,nounits"], stdout=PIPE)
/path/to/python/python3.6/lib/python3.6/subprocess.py:729: in __init__
    restore_signals, start_new_session)
/path/to/python/python3.6/lib/python3.6/subprocess.py:1364: in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
E   FileNotFoundError: [Errno 2] No such file or directory: 'nvidia-smi': 'nvidia-smi'
diviyank commented 4 years ago

Hello, This is strange, what kind of os/environment are you using ? One workaround would be to define CUDA_VISIBLE_DEVICES as "" I will patch this one soon ! Best, Diviyan

petergtz commented 4 years ago

Hi Diviyan,

what kind of os/environment are you using ?

That's on an AWS EC2 instance c3.4xlarge with Amazon Linux on it.

Thanks, Peter

diviyank commented 4 years ago

Hello Peter, Sorry for the delay, This should be fixed in 3a6d2ab , I will release the next version soon (next week) ! Please reopen if the issue still persists.