9
9
import os
10
10
import subprocess
11
11
import sys
12
+ import shutil
12
13
from typing import Optional
13
14
import zipfile
14
15
import requests
22
23
DEFAULT_AMD_OGA_HYBRID_DIR = os .path .join (
23
24
lemonade_install_dir , "install" , "ryzen_ai" , "hybrid"
24
25
)
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
+ )
25
30
26
31
27
32
def download_lfs_file (token , file , output_filename ):
@@ -62,6 +67,13 @@ def download_lfs_file(token, file, output_filename):
62
67
raise ValueError (f"Error: { output_filename } does not exist." )
63
68
64
69
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
+
65
77
def unzip_file (zip_path , extract_to ):
66
78
"""Unzips the specified zip file to the given directory."""
67
79
with zipfile .ZipFile (zip_path , "r" ) as zip_ref :
@@ -116,25 +128,47 @@ def run(
116
128
):
117
129
118
130
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
+
119
153
if yes :
120
154
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 "
122
156
f"Ryzen AI { ryzenai } by providing the `--yes` option. "
123
157
"The license file is available for your review at "
124
158
# 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 "
126
160
)
127
161
else :
128
162
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 "
130
164
"order to install this software. To continue, type the word yes "
131
165
"to assert that you agree and are authorized to agree "
132
166
"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, "
134
168
"which terms and conditions may be reviewed, downloaded and "
135
169
"printed from this link: "
136
170
# 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 "
138
172
)
139
173
140
174
response = input ("Would you like to accept the license (yes/No)? " )
@@ -145,22 +179,6 @@ def run(
145
179
"Exiting because the license was not accepted."
146
180
)
147
181
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
-
164
182
archive_file_name = f"oga_{ ryzenai } .zip"
165
183
archive_file_path = os .path .join (install_dir , archive_file_name )
166
184
@@ -170,9 +188,16 @@ def run(
170
188
token_to_use = os .environ .get ("OGA_TOKEN" )
171
189
172
190
# 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 )
176
201
177
202
# Unzip the file
178
203
print (f"\n Unzipping archive { archive_file_path } \n " )
0 commit comments