Example #1
0
    def _get_license_data():
        try:
            from pytransform import _pytransform
        except Exception:
            # For super mode
            from pytransform import get_user_data
            return get_user_data().decode()

        prototype = PYFUNCTYPE(py_object)
        dlfunc = prototype(('get_registration_code', _pytransform))
        rcode = dlfunc().decode()
        index = rcode.find(';', rcode.find('*CODE:'))
        return rcode[index + 1:]
Example #2
0
def check_gpu():
    gpu_uuids = get_gpu_list()
    assert len(gpu_uuids) == 1  # 1 GPU per instance
    if gpu_uuids:
        if len(gpu_uuids) > 1:
            raise RuntimeError(
                f'This license is issued for one particular GPU, {len(gpu_uuids)} GPUs detected'
            )
        else:
            assert len(gpu_uuids) == 1
            gpu_uuid = gpu_uuids[0]
            if gpu_uuid != get_user_data().decode('utf-8').lower():
                print(f'User data {get_user_data()}')
                raise RuntimeError('A GPU matching the license is not found')
            else:
                print('A GPU license check is passed')
                get_expiration_info()
    else:
        raise RuntimeError(
            'No GPUs detected, this license is issued to particular GPU')