Machine Learning GuideOCDevelAll episodes
MLG 024 Tech Stack
A machine learning tech stack: pandas cleans the data, NumPy hands it to a deep learning framework that runs on the GPU, and scikit-learn scales features and covers shallow algorithms. Also covers TensorFlow vs PyTorch, NVIDIA GPUs and CUDA, cloud GPUs and spot instances, Keras, and splitting a web app server from a GPU job server with a message queue.
Links • Notes and resources at ocdevel.com/mlg/24
- Join the free MLG group: listen to my other AI shows, ask me questions, and talk with other listeners
What does a deep learning framework do? It gives you the building blocks (layers, activation functions, optimizers), automatic differentiation so backpropagation is computed for you, and execution on a GPU. How much faster a GPU runs than a CPU depends on the model and on how much data moves between them.
Which framework? PyTorch is now the default deep learning framework for research and most new work (MLG 010). TensorFlow, usually through Keras, is still widely deployed, and Google's own research has largely moved to JAX. Keras 3 runs on JAX, TensorFlow or PyTorch. Theano stopped development in 2017 and lives on in the PyTensor fork. Caffe is retired.
TensorFlow 2 runs eagerly The graph-building the episode describes, placeholders and feed dicts passed to session.run, is TensorFlow 1. TensorFlow 2 runs eagerly, line by line like ordinary Python, as PyTorch does, and tf.function compiles a function into a graph when you want the speed. Starting in Keras's high-level API and dropping to lower-level code where you need control still works.
GPUs: NVIDIA, AMD and Apple silicon GPU deep learning still centers on NVIDIA's CUDA. You no longer download CUDA and cuDNN by hand: [pip install tensorflow[and-cuda]](https://www.tensorflow.org/install/pip) installs them with TensorFlow, and PyTorch's install selector picks a build for your CUDA version. Building TensorFlow from source for speed is rarely worth it now.
- AMD: PyTorch runs on supported AMD GPUs through ROCm.
- Apple silicon: Macs train on their own GPU through PyTorch's MPS backend, Apple's tensorflow-metal plugin or Apple's MLX, so a Mac works for learning and small models. Official TensorFlow builds have no macOS GPU support of their own.
- Windows: TensorFlow's GPU support needs WSL2, since native Windows GPU builds ended after TensorFlow 2.10. Ubuntu remains a common choice. MLA 012 covers Docker for machine learning.
The GTX 1080 Ti from the episode is several generations old. For a laptop, see Laptop for machine learning and gaming.
Cloud GPUs AWS no longer lists the p2 instances from the episode among its EC2 instance types. Single-GPU options now include G5 (NVIDIA A10G), G6 (L4) and G6e (L40S) instances, and P5/P5e (H100, H200) and P6 (B200, B300) instances handle large training jobs.
Spot Instances still cost up to 90% less than on-demand. EC2 interrupts a Spot Instance mainly when it needs the capacity back, so a high maximum price doesn't guarantee you keep it, and setting a maximum price makes interruptions