This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| 'name': '76_B. Mice', | |
| 'description': 'Modern researches has shown that a flock of hungry mice ' | |
| 'searching for a piece of...', | |
| 'public_tests': {'input': ['3 2 0 2\n0 1 3\n2 5\n'], 'output': ['1\n']}, | |
| 'private_tests': {'input': ['20 18 1 2\n' | |
| '-9999944 -9999861 -9999850 -9999763 -9999656 ' | |
| '-9999517 -9999375 -999927...', | |
| ..., | |
| '7 11 10 20\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| import json | |
| client = boto3.client('sagemaker-runtime') | |
| input_text = """[INST] Hi! [/INST] | |
| Hello! How are you? | |
| [INST] I am great, thanks for asking. Could you help me with a task? [/INST]""" | |
| input_data = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| from pprint import pprint | |
| client = boto3.client('sagemaker') | |
| def main(): | |
| endpoint_config_names = [] | |
| for key in paginate(client.list_endpoint_configs): | |
| endpoint_config_names.append(key['EndpointConfigName']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| from pprint import pprint | |
| client = boto3.client('sagemaker') | |
| def main(): | |
| endpoint_names = [] | |
| for key in paginate(client.list_endpoints): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| from pprint import pprint | |
| client = boto3.client('sagemaker') | |
| def main(): | |
| model_names = [] | |
| for key in paginate(client.list_models): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Quick Fixes | |
| (Cuda Memory out error): Depends on the further error text | |
| Option 1: | |
| import gc | |
| import torch | |
| def report_gpu(): | |
| print(torch.cuda.list_gpu_processes()) | |
| gc.collect() | |
| torch.cuda.empty_cache() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # !pip install transformers datasets evaluate accelerate --quiet | |
| import time | |
| import warnings | |
| warnings.filterwarnings("ignore") | |
| from tqdm.auto import tqdm | |
| import collections | |
| import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| newline, bold, unbold = "\n", "\033[1m", "\033[0m" | |
| text1 = "Translate to German: My name is Arthur" | |
| text2 = "A step by step recipe to make bolognese pasta:" | |
| for text in [text1, text2]: | |
| query_response = query_endpoint(text.encode("utf-8"), endpoint_name=endpoint_name) | |
| generated_text = parse_response(query_response) | |
| print( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import sys | |
| # Set up logging | |
| logger = logging.getLogger(__name__) | |
| logging.basicConfig( | |
| level=logging.getLevelName("INFO"), | |
| handlers=[logging.StreamHandler(sys.stdout)], | |
| format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| del model | |
| del trainer | |
| torch.cuda.empty_cache() |