0

I'm working in azureML Notebook and whenever i try to get a reference to the compute instance using the code bellow :

from azureml.core import Workspace
ws = Workspace.from_config()
from azureml.core import ComputeTarget
compute = ComputeTarget(workspace =ws, name = "MyCompute")

I Get this error :

...

During handling of the above exception, another exception occurred:

UnboundLocalError                         Traceback (most recent call last)
/tmp/ipykernel_6497/1818551949.py in <module>
      3 ws = Workspace.from_config()
      4 from azureml.core import ComputeTarget
----> 5 compute = ComputeTarget(workspace =ws, name = "MyCompute")

/anaconda/envs/myenv/lib/python3.8/site-packages/azureml/core/compute/compute.py in __new__(cls, workspace, name)
     85                     elif compute_type == child._compute_type:
     86                         compute_target = super(ComputeTarget, cls).__new__(child)
---> 87                         compute_target._initialize(workspace, compute_payload)
     88                         return compute_target
     89             else:

/anaconda/envs/myenv/lib/python3.8/site-packages/azureml/core/compute/computeinstance.py in _initialize(self, workspace, obj_dict)
    125 
    126         if not status.created_by_user_name:
--> 127             status.created_by_user_name = ComputeInstance._get_user_display_name(
    128                 self.workspace,
    129                 status.created_by_user_id,

/anaconda/envs/myenv/lib/python3.8/site-packages/azureml/core/compute/computeinstance.py in _get_user_display_name(workspace, user_id, tenant_id)
    965         except Exception:
    966             # Set the display name to None if the user is unauthorized to call graph api
--> 967             if resp.status_code in [401, 403]:
    968                 ComputeInstance._user_display_info[key] = None
    969             return None

UnboundLocalError: local variable 'resp' referenced before assignment

By the way Here is the environment i'm using :

name: myenv
channels:
  - conda-forge
  - pytorch
  - anaconda
  - defaults
dependencies:
  - python==3.8
  - matplotlib
  - numpy
  - pytorch==1.8.0
  - torchvision==0.9.0
  - cpuonly
  - pip
  - pip:
    - azureml-defaults
    - opencv-python-headless
    - 'git+https://github.com/facebookresearch/detectron2.git'

Do you guys have any solutions or suggestions ?

I thank you all in advance !

Note : I deleted the first part of the question because it didn't seem helpful and because stackoverflow kept asking me to add explanations to my question ( or reduce code ) so i reduced the error message...

1 Answers1

0

I guess there was an update. If you guys face the same problem then check the version of azureml-core you have installed, if it's 1.35.0 then that might be the reason you get this problem, for me to solve this problem i changed my environment to :

.
..
...
  - pip
  - pip:
    - azureml-defaults
    - azureml-core==1.34.0
    - opencv-python-headless
    - 'git+https://github.com/facebookresearch/detectron2.git'