Menu

MetalML: run scikit-learn on your Mac's GPU with one import change
📰

MetalML: run scikit-learn on your Mac's GPU with one import change

DEV Community: python·Tudor Iustin·13 days ago
#EIZ8wtL9
#devtopython#devto#dev#metalml#github
Reading 0:00
15s threshold

GitHub: https://github.com/tudor-22/MetalML

MetalML started with a practical idea: keep the familiar scikit-learn workflow while making supported numerical operations available on a Mac's GPU. Instead of introducing a separate training framework, it exposes estimators with the fit, predict and transform methods Python users already know.

# pip install metalml import numpy as np import metalml as ml # was: import sklearn as ml X = np . random . default_rng ( 7 ). normal ( size = ( 5000 , 32 )). astype ( np . float32 ) y = X [:, 0 ] * 3 - X [:, 1 ] model = ml . linear_model . Ridge ( alpha = 1.0 ). fit ( X , y ) print ( model . predict ( X [: 5 ])) print ( model . operation_backends_ ) # which ops ran on Metal vs CPU

Enter fullscreen mode

Exit fullscreen mode

Status

MetalML is experimental. GPU execution is verified on an Intel Mac with a Radeon Pro 5300M; Apple Silicon validation and tuning are next.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.