99import os
1010import subprocess
1111import sys
12+ import shutil
1213from typing import Optional
1314import zipfile
1415import requests
2223DEFAULT_AMD_OGA_HYBRID_DIR = os .path .join (
2324 lemonade_install_dir , "install" , "ryzen_ai" , "hybrid"
2425)
26+ DEFAULT_AMD_OGA_HYBRID_ARTIFACTS_PARENT_DIR = os .path .join (
27+ DEFAULT_AMD_OGA_HYBRID_DIR ,
28+ "hybrid-llm-artifacts_1.3.0_lounge" ,
29+ )
2530
2631
2732def download_lfs_file (token , file , output_filename ):
@@ -62,6 +67,13 @@ def download_lfs_file(token, file, output_filename):
6267 raise ValueError (f"Error: { output_filename } does not exist." )
6368
6469
70+ def download_file (url , output_filename ):
71+ response = requests .get (url )
72+
73+ with open (output_filename , "wb" ) as file :
74+ file .write (response .content )
75+
76+
6577def unzip_file (zip_path , extract_to ):
6678 """Unzips the specified zip file to the given directory."""
6779 with zipfile .ZipFile (zip_path , "r" ) as zip_ref :
@@ -116,25 +128,47 @@ def run(
116128 ):
117129
118130 if ryzenai is not None :
131+ if ryzenai == "npu" :
132+ file = "ryzen_ai_13_ga/npu-llm-artifacts_1.3.0.zip"
133+ install_dir = DEFAULT_AMD_OGA_NPU_DIR
134+ wheels_full_path = os .path .join (install_dir , "amd_oga/wheels" )
135+ license = "https://account.amd.com/content/dam/account/en/licenses/download/amd-end-user-license-agreement.pdf"
136+ license_tag = "Beta "
137+ elif ryzenai == "hybrid" :
138+ file = "https://www.xilinx.com/bin/public/openDownload?filename=hybrid-llm-artifacts_1.3.0_012725.zip"
139+ install_dir = DEFAULT_AMD_OGA_HYBRID_DIR
140+ wheels_full_path = os .path .join (
141+ DEFAULT_AMD_OGA_HYBRID_ARTIFACTS_PARENT_DIR ,
142+ "hybrid-llm-artifacts" ,
143+ "onnxruntime_genai" ,
144+ "wheel" ,
145+ )
146+ license = r"https://www.xilinx.com/bin/public/openDownload?filename=AMD%20End%20User%20License%20Agreement.pdf"
147+ license_tag = ""
148+ else :
149+ raise ValueError (
150+ f"Value passed to ryzenai argument is not supported: { ryzenai } "
151+ )
152+
119153 if yes :
120154 print (
121- "\n You have accepted the AMD Beta Software End User License Agreement for "
155+ f "\n You have accepted the AMD { license_tag } Software End User License Agreement for "
122156 f"Ryzen AI { ryzenai } by providing the `--yes` option. "
123157 "The license file is available for your review at "
124158 # pylint: disable=line-too-long
125- "https://github.com/aigdat/ryzenai-sw-ea/blob/main/ryzen_ai_13_ga/llm-eula-beta-software.pdf \n "
159+ f" { license } \n "
126160 )
127161 else :
128162 print (
129- "\n You must accept the AMD Beta Software End User License Agreement in "
163+ f "\n You must accept the AMD { license_tag } Software End User License Agreement in "
130164 "order to install this software. To continue, type the word yes "
131165 "to assert that you agree and are authorized to agree "
132166 "on behalf of your organization, to the terms and "
133- "conditions, in the Beta Software End User License Agreement, "
167+ f "conditions, in the { license_tag } Software End User License Agreement, "
134168 "which terms and conditions may be reviewed, downloaded and "
135169 "printed from this link: "
136170 # pylint: disable=line-too-long
137- "https://github.com/aigdat/ryzenai-sw-ea/blob/main/ryzen_ai_13_ga/llm-eula-beta-software.pdf \n "
171+ f" { license } \n "
138172 )
139173
140174 response = input ("Would you like to accept the license (yes/No)? " )
@@ -145,22 +179,6 @@ def run(
145179 "Exiting because the license was not accepted."
146180 )
147181
148- if ryzenai == "npu" :
149- file = "ryzen_ai_13_ga/npu-llm-artifacts_1.3.0.zip"
150- install_dir = DEFAULT_AMD_OGA_NPU_DIR
151- wheels_full_path = os .path .join (install_dir , "amd_oga/wheels" )
152- elif ryzenai == "hybrid" :
153- file = "ryzen_ai_13_ga/hybrid-llm-artifacts_1.3.0.zip"
154- install_dir = DEFAULT_AMD_OGA_HYBRID_DIR
155- wheels_full_path = os .path .join (
156- install_dir ,
157- "hybrid-llm-artifacts_1.3.0/hybrid-llm-artifacts/onnxruntime_genai/wheel" ,
158- )
159- else :
160- raise ValueError (
161- f"Value passed to ryzenai argument is not supported: { ryzenai } "
162- )
163-
164182 archive_file_name = f"oga_{ ryzenai } .zip"
165183 archive_file_path = os .path .join (install_dir , archive_file_name )
166184
@@ -170,9 +188,16 @@ def run(
170188 token_to_use = os .environ .get ("OGA_TOKEN" )
171189
172190 # Retrieve the installation artifacts
173- os .makedirs (install_dir , exist_ok = True )
174- print (f"\n Downloading { file } from GitHub LFS to { install_dir } \n " )
175- download_lfs_file (token_to_use , file , archive_file_path )
191+ if os .path .exists (install_dir ):
192+ # Remove any artifacts from a previous installation attempt
193+ shutil .rmtree (install_dir )
194+ os .makedirs (install_dir )
195+ if ryzenai == "npu" :
196+ print (f"\n Downloading { file } from GitHub LFS to { install_dir } \n " )
197+ download_lfs_file (token_to_use , file , archive_file_path )
198+ elif ryzenai == "hybrid" :
199+ print (f"\n Downloading { file } \n " )
200+ download_file (file , archive_file_path )
176201
177202 # Unzip the file
178203 print (f"\n Unzipping archive { archive_file_path } \n " )
0 commit comments