skip to Main Content

So, when I create an Endpoint instance for inferencing, it asks me for a scoring_script.py file (which I provide, no problems), but inside of it, I have a dependency that must be met.

My instance is crashing, because the image I’ve selected for ML work doesn’t have all Azure SDK dependencies, and I need to add custom dependencies. This "dependencies / add file" button asks me for a Python file, not a requirements text file or a Conda YAML file, so I don’t know how to define this script.

How can I specify these dependencies in a script? I couldn’t find it in the documentation.

Dependencies

2

Answers


  1. Chosen as BEST ANSWER

    Turns out that it was an UX problem on the Azure platform. The dependencies file was actually an environment .yml conda file, for example:

    name: pytorch_env
    channels:
      - pytorch
      - defaults
    dependencies:
      - python=3.8
      - numpy
      - matplotlib
      - pandas
      - scikit-learn
      - tqdm
      - pytorch
      - torchvision
      - pip
      - pip:
          - torchsummary
          - tensorboard
    

    I have no idea why the filechooser asks for a .py file, but apparently, it's only to confuse developers like me :).


  2. To include custom dependencies in your scoring script, you can use the pip package manager to install them.

    Here’s an example of how you can include a custom dependency in your scoring script:

    import subprocess
    
    # Install custom dependency
    subprocess.call(['pip', 'install', 'custom_dependency'])
    
    # Import the installed package
    import custom_dependency
    
    # Use the package in your inference code
    result = custom_dependency.run_inference(input_data)
    

    You can add as many dependencies as you need by calling pip install for each one.

    Make sure to specify the correct version of the package you want to install, if necessary, to avoid compatibility issues.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search