paddlenlp

Форк
0
61 строка · 1.9 Кб
1
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

15
from __future__ import absolute_import, division, print_function
16

17
import sys
18

19
from .device import get_device_and_mapping
20
from .log import logger
21

22

23
def check_version():
24
    """
25
    Log error and exit when the installed version of paddlepaddle is
26
    not satisfied.
27
    """
28
    err = (
29
        "PaddlePaddle version 1.8.0 or higher is required, "
30
        "or a suitable develop version is satisfied as well. \n"
31
        "Please make sure the version is good with your code."
32
    )
33
    try:
34
        pass
35
        # paddle.utils.require_version('0.0.0')
36
    except Exception:
37
        logger.error(err)
38
        sys.exit(1)
39

40

41
def check_device(device):
42
    """
43
    Log error and exit when using paddlepaddle cpu version.
44
    """
45
    err = (
46
        "You are using paddlepaddle %s version! Please try to \n"
47
        "1. install paddlepaddle-%s to run model on %s \nor 2. set the config option 'Global.device' to %s."
48
    )
49

50
    d, supported_device_map = get_device_and_mapping()
51

52
    assert (
53
        device in supported_device_map
54
    ), f"the device({device}) to check is not supported by now.Now the paddle only supports: {supported_device_map.keys()}"
55
    err = err % (d, device, device, d)
56

57
    try:
58
        assert supported_device_map[device]
59
    except AssertionError:
60
        logger.error(err)
61
        sys.exit(1)
62

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.