1717from subprocess import Popen , PIPE , STDOUT
1818from typing import Union , List , Tuple , Dict
1919import yaml
20+ import re
2021
2122import ads
2223from ads .common .oci_client import OCIClientFactory
@@ -160,7 +161,14 @@ def build_image(
160161 )
161162 proc = _build_custom_operator_image (gpu , source_folder , dst_image )
162163 else :
163- image , dockerfile , target = _get_image_name_dockerfile_target (image_type , gpu )
164+ # https://stackoverflow.com/questions/66842004/get-the-processor-type-using-python-for-apple-m1-processor-gives-me-an-intel-pro
165+ import cpuinfo
166+ # Just get the manufacturer of the processors
167+ manufacturer = cpuinfo .get_cpu_info ().get ('brand_raw' )
168+ arch = 'arm' if re .search ("apple m\d " , manufacturer , re .IGNORECASE ) else 'other'
169+ print (f"The local machine's platform is { arch } ." )
170+ image , dockerfile , target = _get_image_name_dockerfile_target (image_type , gpu , arch )
171+ print (f"dockerfile used is { dockerfile } " )
164172 command = [
165173 "docker" ,
166174 "build" ,
@@ -186,14 +194,15 @@ def build_image(
186194 raise RuntimeError ("Docker build failed." )
187195
188196
189- def _get_image_name_dockerfile_target (type : str , gpu : bool ) -> str :
197+ def _get_image_name_dockerfile_target (type : str , gpu : bool , arch : str ) -> str :
190198 look_up = {
191- ("job-local" , False ): (ML_JOB_IMAGE , "Dockerfile.job" , None ),
192- ("job-local" , True ): (ML_JOB_GPU_IMAGE , "Dockerfile.job.gpu" , None ),
193- ("ads-ops-base" , False ): (OPS_IMAGE_BASE , "Dockerfile" , "base" ),
194- ("ads-ops-base" , True ): (OPS_IMAGE_GPU_BASE , "Dockerfile.gpu" , "base" ),
199+ ("job-local" , False , "arm" ): (ML_JOB_IMAGE , "Dockerfile.job.arm" , None ),
200+ ("job-local" , False , "other" ): (ML_JOB_IMAGE , "Dockerfile.job" , None ),
201+ ("job-local" , True , "other" ): (ML_JOB_GPU_IMAGE , "Dockerfile.job.gpu" , None ),
202+ ("ads-ops-base" , False , "other" ): (OPS_IMAGE_BASE , "Dockerfile" , "base" ),
203+ ("ads-ops-base" , True , "other" ): (OPS_IMAGE_GPU_BASE , "Dockerfile.gpu" , "base" ),
195204 }
196- return look_up [(type , gpu )]
205+ return look_up [(type , gpu , arch )]
197206
198207
199208@runtime_dependency (module = "docker" , install_from = OptionalDependency .OPCTL )
0 commit comments