Distillation and Finetuning Guide- How to resolve CredentialUnavailableError from step 7 in Notebook 2 of the guide?
Hello.
Question: Please, how do I resolve the CredentialUnavailableError I get from running the following code?
Context/Additional Info: How to resolve CredentialUnavailableError from step 7 (ran on Jupyter Notebook in Azure ML Studio) in Notebook 2 of the Distillation and Finetuning guide. The code comes from this notebook under step 7, Fine-tune with Low-Rank Adaptation (LoRA). The overall goal is distillation and then finetuning. However, my immediate concern is how to resolve the error below.
I have looked at the links provided in the error message but I haven't been able to resolve it yet. I would appreciate any advice!
Thanks!
Code:
! olive finetune \
--method lora \
--model_name_or_path azureml://registries/azureml/models/Phi-4-mini-instruct/versions/1 \
--trust_remote_code \
--data_name json \
--data_files ./data/train_data.jsonl \
--text_template "<|user|>{Question}<|end|><|assistant|>{Answer}<|end|>" \
--max_steps 100 \
--output_path models/phi-4-mini/ft \
--target_modules "q_proj","k_proj","v_proj","o_proj","gate_proj","up_proj","down_proj" \
--log_level 1
Error:
Loading HuggingFace model from {'type': 'azureml_registry_model', 'registry_name': 'azureml', 'name': 'Phi-4-mini-instruct', 'version': '1'}
[2025-08-05 13:54:52,125] [INFO] [run.py:142:run_engine] Running workflow default_workflow
[2025-08-05 13:54:52,136] [INFO] [cache.py:138:__init__] Using cache directory: /afh/projects/Lab329-AI-Env-ca0a8bc0-bbd4-4a19-a49b-81aa0920fdeb/shared/Build25-LAB329/Lab329/Notebook/.olive-cache/default_workflow
[2025-08-05 13:54:52,293] [INFO] [accelerator_creator.py:217:create_accelerators] Running workflow on accelerator specs: gpu-cuda
[2025-08-05 13:54:56,732] [WARNING] [utils.py:552:get_credentials] Using InteractiveBrowserCredential since of default credential errors
Traceback (most recent call last):
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/common/utils.py", line 549, in get_credentials
credential.get_token("https://management.azure.com/.default")
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/identity/_credentials/default.py", line 227, in get_token
token = super().get_token(*scopes, claims=claims, tenant_id=tenant_id, **kwargs)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/identity/_credentials/chained.py", line 153, in get_token
raise ClientAuthenticationError(message=message)
azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot this issue.
ManagedIdentityCredential: string indices must be integers
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
Traceback (most recent call last):
File "/anaconda/envs/azureml_py38/bin/olive", line 8, in <module>
sys.exit(main())
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/cli/launcher.py", line 64, in main
service.run()
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/cli/finetune.py", line 83, in run
self._run_workflow()
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/cli/base.py", line 42, in _run_workflow
output = olive_run(run_config)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/workflows/run/run.py", line 255, in run
return run_engine(package_config, run_config)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/workflows/run/run.py", line 199, in run_engine
return engine.run(
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/engine/engine.py", line 214, in run
self.initialize(log_to_file, log_severity_level)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/engine/engine.py", line 119, in initialize
pass_config.config = self.cache.prepare_resources_for_local(pass_config.config)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/cache.py", line 312, in prepare_resources_for_local
set_nested_dict_value(config, resource_key, self.get_local_path(resource_path))
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/cache.py", line 328, in get_local_path
return self.get_local_path_or_download(resource_path).get_path()
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/cache.py", line 358, in get_local_path_or_download
local_resource_path = create_resource_path(resource_path.save_to_dir(save_dir))
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/resource_path.py", line 441, in save_to_dir
ml_client = azureml_client_config.create_registry_client(self.config.registry_name)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/olive/azureml/azureml_client.py", line 120, in create_registry_client
return MLClient(credential=get_credentials(self.default_auth_params), registry_name=registry_name)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_ml_client.py", line 255, in __init__
) = get_registry_client(
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_utils/_registry_utils.py", line 218, in get_registry_client
registry_discovery.get_registry_service_client()
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_utils/_registry_utils.py", line 57, in get_registry_service_client
self._get_registry_details()
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_utils/_registry_utils.py", line 45, in _get_registry_details
response = self.service_client_registry_discovery_client.registry_management_non_workspace.registry_management_non_workspace( # pylint: disable=line-too-long
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 119, in wrapper_use_tracer
return func(*args, **kwargs)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_restclient/registry_discovery/operations/_registry_management_non_workspace_operations.py", line 111, in registry_management_non_workspace
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/_base.py", line 242, in run
return first_node.send(pipeline_request)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/_base.py", line 98, in send
response = self.next.send(request)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/_base.py", line 98, in send
response = self.next.send(request)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/_base.py", line 98, in send
response = self.next.send(request)
[Previous line repeated 2 more times]
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/mgmt/core/policies/_base.py", line 95, in send
response = self.next.send(request)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/policies/_redirect.py", line 205, in send
response = self.next.send(request)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/policies/_retry.py", line 544, in send
response = self.next.send(request)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/policies/_authentication.py", line 157, in send
self.on_request(request)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/policies/_authentication.py", line 132, in on_request
self._request_token(*self._scopes)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/policies/_authentication.py", line 108, in _request_token
self._token = self._get_token(*scopes, **kwargs)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/core/pipeline/policies/_authentication.py", line 98, in _get_token
return cast(SupportsTokenInfo, self._credential).get_token_info(*scopes, options=options)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/identity/_internal/interactive.py", line 173, in get_token_info
return self._get_token_base(*scopes, options=options, base_method_name="get_token_info")
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/identity/_internal/interactive.py", line 219, in _get_token_base
result = self._request_token(*scopes, claims=claims, tenant_id=tenant_id, enable_cae=enable_cae, **kwargs)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/identity/_internal/decorators.py", line 75, in wrapper
return fn(*args, **kwargs)
File "/anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/identity/_credentials/browser.py", line 123, in _request_token
raise CredentialUnavailableError(message="Failed to open a browser")
azure.identity._exceptions.CredentialUnavailableError: Failed to open a browser