1
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
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
7
# http://www.apache.org/licenses/LICENSE-2.0
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.
15
from __future__ import absolute_import, division, print_function
19
from .device import get_device_and_mapping
20
from .log import logger
25
Log error and exit when the installed version of paddlepaddle is
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."
35
# paddle.utils.require_version('0.0.0')
41
def check_device(device):
43
Log error and exit when using paddlepaddle cpu version.
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."
50
d, supported_device_map = get_device_and_mapping()
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)
58
assert supported_device_map[device]
59
except AssertionError: