Update README.md
Browse filesimport sagemaker
import boto3
from sagemaker.huggingface import HuggingFace
try:
role = sagemaker.get_execution_role()
except ValueError:
iam = boto3.client('iam')
role = iam.get_role(RoleName='sagemaker_execution_role')['Role']['Arn']
hyperparameters = {
'model_name_or_path':'QuantFactory/diffullama-GGUF',
'output_dir':'/opt/ml/model'
# add your remaining hyperparameters
# more info here https://github.com/huggingface/transformers/tree/v4.49.0/path/to/script
}
# git configuration to download our fine-tuning script
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.49.0'}
# creates Hugging Face estimator
huggingface_estimator = HuggingFace(
entry_point='train.py',
source_dir='./path/to/script',
instance_type='ml.p3.2xlarge',
instance_count=1,
role=role,
git_config=git_config,
transformers_version='4.49.0',
pytorch_version='2.5.1',
py_version='py311',
hyperparameters = hyperparameters
)
# starting the train job
huggingface_estimator.fit()
|
@@ -265,4 +265,40 @@ pipe = DiffusionPipeline.from_pretrained(
|
|
| 265 |
|
| 266 |
# Move to GPU ifailable
|
| 267 |
if torch.cuda.is_available():
|
| 268 |
-
pipe = pipe.to("cuda")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
|
| 266 |
# Move to GPU ifailable
|
| 267 |
if torch.cuda.is_available():
|
| 268 |
+
pipe = pipe.to("cuda")
|
| 269 |
+
import sagemaker
|
| 270 |
+
import boto3
|
| 271 |
+
from sagemaker.huggingface import HuggingFace
|
| 272 |
+
|
| 273 |
+
try:
|
| 274 |
+
role = sagemaker.get_execution_role()
|
| 275 |
+
except ValueError:
|
| 276 |
+
iam = boto3.client('iam')
|
| 277 |
+
role = iam.get_role(RoleName='sagemaker_execution_role')['Role']['Arn']
|
| 278 |
+
|
| 279 |
+
hyperparameters = {
|
| 280 |
+
'model_name_or_path':'QuantFactory/diffullama-GGUF',
|
| 281 |
+
'output_dir':'/opt/ml/model'
|
| 282 |
+
# add your remaining hyperparameters
|
| 283 |
+
# more info here https://github.com/huggingface/transformers/tree/v4.49.0/path/to/script
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
# git configuration to download our fine-tuning script
|
| 287 |
+
git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.49.0'}
|
| 288 |
+
|
| 289 |
+
# creates Hugging Face estimator
|
| 290 |
+
huggingface_estimator = HuggingFace(
|
| 291 |
+
entry_point='train.py',
|
| 292 |
+
source_dir='./path/to/script',
|
| 293 |
+
instance_type='ml.p3.2xlarge',
|
| 294 |
+
instance_count=1,
|
| 295 |
+
role=role,
|
| 296 |
+
git_config=git_config,
|
| 297 |
+
transformers_version='4.49.0',
|
| 298 |
+
pytorch_version='2.5.1',
|
| 299 |
+
py_version='py311',
|
| 300 |
+
hyperparameters = hyperparameters
|
| 301 |
+
)
|
| 302 |
+
|
| 303 |
+
# starting the train job
|
| 304 |
+
huggingface_estimator.fit()
|