示例#1
0
def test_gpu_not_available():
    """
    Ensures that xlogit detects that GPU is not available based on CuPy's
    installation status

    """
    assert not MixedLogit.check_if_gpu_available()
示例#2
0
"""
This file executes the benchmark. Check the README.md file in this folder
to make sure all the requirments are satisfied.
"""

import os
from tools import init_profiler_output_files, log
import sys
# sys.path.append("../../")  # Path of xlogit library root folder.
from xlogit import MixedLogit

MixedLogit.check_if_gpu_available()
mini = len(sys.argv) == 2 and sys.argv[1] == 'mini'
init_profiler_output_files()


def profile_range_draws(command, r_draws, dataset, usegpu=False):
    log("\n\n=== " + dataset + " dataset. " + command.split()[1] +
        ('(using GPU)' if usegpu else '') + " ===")
    log("Ndraws Time(s) Log-Likeli. RAM(GB) GPU(GB) Converg.")
    for r in range(1, r_draws + 1):
        os.system("{} {} {} {} prof".format(command, r * 100, dataset,
                                            usegpu * 1))


def profile_range_draws_and_cores(command, r_draws, r_cores):
    log("\n\n=== artificial dataset. " + command.split()[1] + " ===")
    for n_draws in r_draws:
        for n_cores in r_cores:
            os.system("{} {} {}".format(command, n_draws, n_cores))