prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Installing Nvidia drivers doesn't work
  When building the AMI, the `install-nvidia-drivers.sh` fails with base AMI `'ami-9109beee` (latest deep learning ami) and Nvidia drivers 384.125. I was able to get it to run with the `--install-libglvnd` flag. But, when I start an instance with the resulting AMI, running `nvidia-smi` reports that the drivers aren't installed. At the moment, the latest base AMI has the Nvidia drivers we need, so I've commented out installing them, but in the future we may need this.
  
  </issue>
  <code>
  [start of deployment/packer/driver.py]
  1 """Helper functions to handle AMI creation with packer"""
  2 
  3 import boto3
  4 import os
  5 from os.path import dirname
  6 import subprocess
  7 import re
  8 import logging
  9 
  10 LOGGER = logging.getLogger(__file__)
  11 LOGGER.addHandler(logging.StreamHandler())
  12 LOGGER.setLevel(logging.INFO)
  13 
  14 
  15 def get_recent_batch_ami(aws_profile):
  16     """Finds the most recent Deep Learning AMI"""
  17     filters = [
  18         {'Name': 'architecture', 'Values': ['x86_64']},
  19         {'Name': 'owner-id', 'Values': ['898082745236']},
  20         {'Name': 'virtualization-type', 'Values': ['hvm']},
  21     ]
  22     sess = boto3.Session(profile_name=aws_profile)
  23     ec2 = sess.client("ec2")
  24     images = filter(
  25         lambda x: re.search("Deep Learning AMI Amazon Linux .*", x['Name']),
  26         ec2.describe_images(Filters=filters)['Images'])
  27     images.sort(key=lambda x: x["CreationDate"])
  28 
  29     LOGGER.info("Found AMI: %s", images[-1]["ImageId"])
  30 
  31     return images[-1]["ImageId"]
  32 
  33 
  34 def get_project_root():
  35     return dirname(dirname(dirname(os.path.realpath(__file__))))
  36 
  37 
  38 def get_git_sha():
  39     """Function that executes Git to determine the current SHA"""
  40     git_command = ['git',
  41                    'rev-parse',
  42                    '--short',
  43                    'HEAD']
  44 
  45     src_dir = os.path.abspath(get_project_root())
  46 
  47     return subprocess.check_output(git_command, cwd=src_dir).rstrip()
  48 
  49 
  50 def get_git_branch():
  51     """Function that executes Git to determine the current branch"""
  52     git_command = ['git',
  53                    'rev-parse',
  54                    '--abbrev-ref',
  55                    'HEAD']
  56 
  57     return subprocess.check_output(git_command).rstrip()
  58 
  59 
  60 def run_packer(aws_profile, source_ami=None, aws_region="us-east-1"):
  61     """Function to run packer
  62 
  63     Args:
  64       aws_profile (str): aws profile name to use for authentication
  65       source_ami (str): AMI to use for Packer Builder
  66       aws_region (str): AWS region to user for Packer Builder
  67     """
  68 
  69     # Get AWS credentials based on profile
  70     env = os.environ.copy()
  71     env["AWS_PROFILE"] = aws_profile
  72 
  73     packer_template_path = os.path.join(get_project_root(),
  74                                         'deployment', 'packer', 'template.js')
  75 
  76     LOGGER.info('Creating GPU Workload AMI in %s region', aws_region)
  77 
  78     packer_command = [
  79         'packer', 'build',
  80         '-var', 'raster_vision_gpu_version={}'.format(get_git_sha()),
  81         '-var', 'aws_region={}'.format(aws_region),
  82         '-var', 'aws_gpu_ami={}'.format(source_ami or
  83                                         get_recent_batch_ami(aws_profile)),
  84         '-var', 'branch={}'.format(get_git_branch())]
  85 
  86     packer_command.append(packer_template_path)
  87 
  88     LOGGER.info('Running Packer Command: %s', ' '.join(packer_command))
  89     subprocess.check_call(packer_command, env=env)
  90
  [end of deployment/packer/driver.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/deployment/packer/driver.py b/deployment/packer/driver.py
  --- a/deployment/packer/driver.py
  +++ b/deployment/packer/driver.py
  @@ -22,7 +22,7 @@
       sess = boto3.Session(profile_name=aws_profile)
       ec2 = sess.client("ec2")
       images = filter(
  -        lambda x: re.search("Deep Learning AMI Amazon Linux .*", x['Name']),
  +        lambda x: re.search("Deep Learning Base AMI \(Amazon Linux\) (.*)", x['Name']),
           ec2.describe_images(Filters=filters)['Images'])
       images.sort(key=lambda x: x["CreationDate"])
  
verification_info: {"golden_diff": "diff --git a/deployment/packer/driver.py b/deployment/packer/driver.py\n--- a/deployment/packer/driver.py\n+++ b/deployment/packer/driver.py\n@@ -22,7 +22,7 @@\n     sess = boto3.Session(profile_name=aws_profile)\n     ec2 = sess.client(\"ec2\")\n     images = filter(\n-        lambda x: re.search(\"Deep Learning AMI Amazon Linux .*\", x['Name']),\n+        lambda x: re.search(\"Deep Learning Base AMI \\(Amazon Linux\\) (.*)\", x['Name']),\n         ec2.describe_images(Filters=filters)['Images'])\n     images.sort(key=lambda x: x[\"CreationDate\"])\n", "issue": "Installing Nvidia drivers doesn't work\nWhen building the AMI, the `install-nvidia-drivers.sh` fails with base AMI `'ami-9109beee` (latest deep learning ami) and Nvidia drivers 384.125. I was able to get it to run with the `--install-libglvnd` flag. But, when I start an instance with the resulting AMI, running `nvidia-smi` reports that the drivers aren't installed. At the moment, the latest base AMI has the Nvidia drivers we need, so I've commented out installing them, but in the future we may need this.\n", "before_files": [{"content": "\"\"\"Helper functions to handle AMI creation with packer\"\"\"\n\nimport boto3\nimport os\nfrom os.path import dirname\nimport subprocess\nimport re\nimport logging\n\nLOGGER = logging.getLogger(__file__)\nLOGGER.addHandler(logging.StreamHandler())\nLOGGER.setLevel(logging.INFO)\n\n\ndef get_recent_batch_ami(aws_profile):\n    \"\"\"Finds the most recent Deep Learning AMI\"\"\"\n    filters = [\n        {'Name': 'architecture', 'Values': ['x86_64']},\n        {'Name': 'owner-id', 'Values': ['898082745236']},\n        {'Name': 'virtualization-type', 'Values': ['hvm']},\n    ]\n    sess = boto3.Session(profile_name=aws_profile)\n    ec2 = sess.client(\"ec2\")\n    images = filter(\n        lambda x: re.search(\"Deep Learning AMI Amazon Linux .*\", x['Name']),\n        ec2.describe_images(Filters=filters)['Images'])\n    images.sort(key=lambda x: x[\"CreationDate\"])\n\n    LOGGER.info(\"Found AMI: %s\", images[-1][\"ImageId\"])\n\n    return images[-1][\"ImageId\"]\n\n\ndef get_project_root():\n    return dirname(dirname(dirname(os.path.realpath(__file__))))\n\n\ndef get_git_sha():\n    \"\"\"Function that executes Git to determine the current SHA\"\"\"\n    git_command = ['git',\n                   'rev-parse',\n                   '--short',\n                   'HEAD']\n\n    src_dir = os.path.abspath(get_project_root())\n\n    return subprocess.check_output(git_command, cwd=src_dir).rstrip()\n\n\ndef get_git_branch():\n    \"\"\"Function that executes Git to determine the current branch\"\"\"\n    git_command = ['git',\n                   'rev-parse',\n                   '--abbrev-ref',\n                   'HEAD']\n\n    return subprocess.check_output(git_command).rstrip()\n\n\ndef run_packer(aws_profile, source_ami=None, aws_region=\"us-east-1\"):\n    \"\"\"Function to run packer\n\n    Args:\n      aws_profile (str): aws profile name to use for authentication\n      source_ami (str): AMI to use for Packer Builder\n      aws_region (str): AWS region to user for Packer Builder\n    \"\"\"\n\n    # Get AWS credentials based on profile\n    env = os.environ.copy()\n    env[\"AWS_PROFILE\"] = aws_profile\n\n    packer_template_path = os.path.join(get_project_root(),\n                                        'deployment', 'packer', 'template.js')\n\n    LOGGER.info('Creating GPU Workload AMI in %s region', aws_region)\n\n    packer_command = [\n        'packer', 'build',\n        '-var', 'raster_vision_gpu_version={}'.format(get_git_sha()),\n        '-var', 'aws_region={}'.format(aws_region),\n        '-var', 'aws_gpu_ami={}'.format(source_ami or\n                                        get_recent_batch_ami(aws_profile)),\n        '-var', 'branch={}'.format(get_git_branch())]\n\n    packer_command.append(packer_template_path)\n\n    LOGGER.info('Running Packer Command: %s', ' '.join(packer_command))\n    subprocess.check_call(packer_command, env=env)\n", "path": "deployment/packer/driver.py"}]}