|
18 | 18 |
|
19 | 19 | from botocore.exceptions import ClientError
|
20 | 20 |
|
21 |
| -from accelerate.commands.estimate import estimate_command_parser, gather_data |
22 | 21 | from sagemaker import Session
|
23 |
| -from sagemaker.model import Model |
24 | 22 | from sagemaker import instance_types_gpu_info
|
25 | 23 |
|
26 | 24 | logger = logging.getLogger(__name__)
|
@@ -116,18 +114,23 @@ def _format_instance_type(instance_type: str) -> str:
|
116 | 114 | return ec2_instance
|
117 | 115 |
|
118 | 116 |
|
119 |
| -def _total_inference_model_size_mib(model: Model, dtype: str) -> int: |
| 117 | +def _total_inference_model_size_mib(model: str, dtype: str) -> int: |
120 | 118 | """Calculates the model size from HF accelerate
|
121 | 119 |
|
122 | 120 | This function gets the model size from accelerate. It also adds a
|
123 | 121 | padding and converts to size MiB. When performing inference, expect
|
124 | 122 | to add up to an additional 20% to the given model size as found by EleutherAI.
|
125 | 123 | """
|
126 |
| - args = estimate_command_parser().parse_args([model, "--dtypes", dtype]) |
127 |
| - |
128 |
| - output = gather_data( |
129 |
| - args |
130 |
| - ) # "dtype", "Largest Layer", "Total Size Bytes", "Training using Adam" |
| 124 | + try: |
| 125 | + from accelerate.commands.estimate import estimate_command_parser, gather_data |
| 126 | + args = estimate_command_parser().parse_args([model, "--dtypes", dtype]) |
| 127 | + |
| 128 | + output = gather_data( |
| 129 | + args |
| 130 | + ) # "dtype", "Largest Layer", "Total Size Bytes", "Training using Adam" |
| 131 | + except ImportError: |
| 132 | + logger.error("Install HuggingFace extras dependencies using pip install 'sagemaker[" |
| 133 | + "huggingface]>=2.212.0'") |
131 | 134 |
|
132 | 135 | if output is None:
|
133 | 136 | raise ValueError(f"Could not get Model size for {model}")
|
|
0 commit comments