AI

Best Deep Learning and PyTorch Books: 9 Picks Checked for PyTorch 2

This post contains affiliate links. If you buy through them, we may earn a small commission at no extra cost to you. Learn more.

Some of the bestselling PyTorch books still ship code written before PyTorch 2 existed. That matters more than the author or the cover, because a book built on an older release teaches habits the current library has moved past, and its notebooks fail in ways that look like your mistake.

Original content from computingforgeeks.com - post 176668

We checked every candidate’s companion repository for the PyTorch version its code targets, then checked edition dates, publishers and Amazon US listings on October 22, 2026. This list of the best deep learning and PyTorch books keeps nine. Six carry code on PyTorch 2, Moroney’s pins no version, and the other two are theory books whose ideas don’t expire: Prince’s, with PyTorch in a few of its notebooks, and Bishop’s, with no code at all.

Compare the nine deep learning books

BookBest forPyTorch in the codePagesPublished
Deep Learning with PyTorch, 2nd ed.Learning the library properly2.x5442026
Hands-On ML with Scikit-Learn and PyTorchClassic ML into deep learning2.8 or newer8782025
AI and ML for Coders in PyTorchCoders who skip the mathNot pinned4442025
Dive into Deep LearningTheory with runnable code2.0 in print5742023
Understanding Deep LearningModern theory, clear figuresSome notebooks5442023
Deep Learning: Foundations and ConceptsA reference you keepNo code6692023
Build a Large Language Model (From Scratch)Building a GPT model2.2.2 or newer3682024
Build a Reasoning Model (From Scratch)Reasoning and RL training2.10 or newer4402026
AI Systems Performance EngineeringMaking training fastTwo chapters1,0622025

The version column comes from each book’s own repository or print setup, not from the cover. Print copies ran from about $30 to $85 on October 22, and book prices move weekly, so check the current price before you buy.

Check the PyTorch version before you buy

PyTorch 2.0 shipped in March 2023 and added torch.compile, so anything printed before that date teaches the old way to speed up a model. A few popular books fall on the wrong side of that line:

  • Machine Learning with PyTorch and Scikit-Learn (2022): code captured on PyTorch 1.10
  • Programming PyTorch for Deep Learning (2019): repository pins PyTorch 1.6
  • Deep Learning with PyTorch, first edition (2020): replaced by the 2026 edition
  • Deep Learning (Goodfellow, 2016): no transformer chapter, free online

Raschka’s 2022 book still sells well and the concepts hold up, so it is not useless. Most of its training loops still run on PyTorch 2, since 2.0 kept backward compatibility. The text chapters are the real break: chapters 15 and 16 rely on torchtext, which stopped development in 2024, and the saved outputs show PyTorch 1.10. If you want his writing on current code, his two Manning books further down use PyTorch 2.

Learn the library first

These three teach PyTorch itself: tensors, autograd, training loops and the parts of the ecosystem you will touch every day. Pick one by how much math you want alongside the code.

Deep Learning with PyTorch, Second Edition

Deep Learning with PyTorch Second Edition book cover
Deep Learning with PyTorch, Second Edition by Howard Huang, Eli Stevens, Luca Antiga and Thomas Viehmann. Image: Manning.

This is the book to learn PyTorch properly from, and the 2026 edition adds a PyTorch core developer, Howard Huang, to the original authors. Part 1 covers tensors, the mechanics of learning and convolutional networks. Part 2 adds chapters on how transformers work, diffusion models, training on multiple GPUs and deploying to production.

Five of the 17 chapters, 11 to 15, are one long project carried over from the first edition: a lung nodule detector on CT scans. That suits you if you want one end-to-end build, because you see data loading, training and evaluation applied to one real problem. The chapters around it cover transformers, diffusion, multi-GPU training and serving, so you still get breadth. Make sure the listing says Second Edition. It ran about $50 to $55.

Hands-On Machine Learning with Scikit-Learn and PyTorch

Hands-On Machine Learning with Scikit-Learn and PyTorch book cover
Hands-On Machine Learning with Scikit-Learn and PyTorch by Aurélien Géron. Image: O’Reilly Media.

Géron rebuilt his bestseller around PyTorch in late 2025, and the companion repository pins PyTorch 2.8 or newer. It starts with classic machine learning in scikit-learn, then moves through neural networks, transformers for text and vision, and a chapter on speeding transformers up. Pick it if you also need the non-deep parts of machine learning.

It is a long book at 878 pages, and its classic ML half overlaps our machine learning book list. The Keras and TensorFlow third edition is a separate parallel book, so buy this PyTorch one. It ran about $63 to $78 depending on the seller, and Amazon itself sold it at the top of that range.

AI and ML for Coders in PyTorch

AI and ML for Coders in PyTorch book cover
AI and ML for Coders in PyTorch by Laurence Moroney. Image: O’Reilly Media.

Laurence Moroney writes for developers who want working models without the calculus. The 20 chapters run from vision and text to serving models, Ollama, retrieval-augmented generation, and LoRA tuning for image models with Hugging Face Diffusers. At about $32, it’s one of the cheaper books on this shelf.

It has far fewer Amazon reviews than the rest of the list, and its repository pins no PyTorch version, so you cannot tell from the code which release the examples were tested on. Read a chapter preview before you buy. Skip it if you want to understand why models train, not just how to call them.

Understand why models train

Code alone gets you a model that runs. These three explain why it converges, why it overfits and what attention actually computes, and all three are free to read online.

Dive into Deep Learning

Dive into Deep Learning book cover
Dive into Deep Learning by Aston Zhang, Zachary C. Lipton, Mu Li and Alexander J. Smola. Image: Cambridge University Press.

D2L pairs every idea with code you can run, and the authors chose PyTorch as its main framework. The print edition installs PyTorch 2.0 and warns that some code may break on later releases, and the free online version at d2l.ai pins the same 2.0 release. Create the Python 3.9 environment the site specifies, because its pinned packages are unlikely to install on a current Python. It suits self-learners who want theory and practice in one place.

At about $30 it’s the cheapest paperback here, and Amazon had only a few copies left on our check date. Buy it if you like reading away from the screen, and use the website when you want to search or copy code, since both carry the same examples.

Understanding Deep Learning

Understanding Deep Learning book cover
Understanding Deep Learning by Simon J. D. Prince. Image: MIT Press.

Simon Prince explains modern deep learning, including transformers and diffusion models, with the clearest figures of any book here. A free PDF lives on the book’s site, and a minority of its notebooks use PyTorch while the rest stick to NumPy. It also sits on our machine learning book list as the entry point to deep learning theory.

Only third-party sellers had it on Amazon when we checked, at about $85 for the hardcover. Read the PDF first, and buy the print copy if you end up living in it, since a third-party price can swing from week to week and the PDF loses nothing but the binding.

Deep Learning: Foundations and Concepts

Deep Learning Foundations and Concepts book cover
Deep Learning: Foundations and Concepts by Christopher M. Bishop and Hugh Bishop. Image: Springer.

The Bishops wrote the reference shelf book: concepts through text, diagrams, math and pseudo-code, with no framework code to go stale. It’s the one to keep when you need the derivation behind a method you read about in a paper. A free online version exists, and the hardcover lays flat on a desk.

There is no PyTorch here at all, so pair it with a book from the first group. It ran about $49, and it’s the theory hardcover Amazon sells itself, at a little over half the price of Prince’s third-party listing.

Build modern models from scratch

Once the library and the theory make sense, build something current. Sebastian Raschka’s two Manning books both write every layer by hand in PyTorch, and their repositories pin recent releases.

Build a Large Language Model (From Scratch)

Build a Large Language Model From Scratch book cover
Build a Large Language Model (From Scratch) by Sebastian Raschka. Image: Manning.

You build a GPT-style model step by step: text data, attention, the model itself, pretraining, then classification and instruction fine-tuning. An appendix introduces PyTorch, and Manning says the model runs on any modern laptop with optional GPU use. It was the bestselling book on our shortlist.

It also leads our LLM engineering book list, so read that list if you want the application side next. It ran about $47 to $48.

Build a Reasoning Model (From Scratch)

Build a Reasoning Model From Scratch book cover
Build a Reasoning Model (From Scratch) by Sebastian Raschka. Image: Manning.

The 2026 follow-up starts from a pretrained Qwen3 base and adds reasoning: evaluation, inference-time scaling, self-refinement, reinforcement learning with GRPO and distillation. Its repository pins PyTorch 2.10, the newest code on this list. The early chapters run on a CPU, and the repository recommends a GPU for chapters 5 and 6.

Raschka wrote it as a standalone book, and chapter 2 loads a pretrained model to generate text, so you can start here. The LLM book is useful background if you want to see how that model was built first. The reinforcement learning chapters also reward a GPU, so budget for one or rent time in the cloud before you reach them. It ran about $48, sold by Amazon.

Make training fast

Speed is the last skill most PyTorch books skip. This one covers it, though it is an infrastructure book more than a PyTorch book.

AI Systems Performance Engineering

AI Systems Performance Engineering book cover
AI Systems Performance Engineering by Chris Fregly. Image: O’Reilly Media.

Chris Fregly spends two of his 20 chapters on profiling and tuning PyTorch and on the PyTorch compiler, Triton and XLA backends. The rest covers GPUs, CUDA, networking, storage and inference serving, and it ends with a performance checklist of more than 175 items. Read it when your model works and the cloud bill is the problem.

It runs past 1,000 pages, and only third-party sellers had it on Amazon when we checked, at about $70 to $80. If you want a broad PyTorch book that includes training and production chapters, Mastering PyTorch, Second Edition is a shorter option that Amazon sells directly for about $35. Our MLOps book list covers what happens after training.

Set up a GPU before the training chapters

Every pick except Bishop ships code, and the early chapters of the tutorial books run on a CPU. Training chapters are different. The diffusion and reinforcement learning chapters crawl without a CUDA GPU, the multi-GPU chapter in Deep Learning with PyTorch runs as several CPU processes but need two or more GPUs to show a real speedup, and Fregly’s examples are PyTorch and CUDA C++ tuned for NVIDIA Blackwell data-center GPUs, so plan the hardware before you reach them:

If you would rather use Keras, Deep Learning with Python, Third Edition puts Keras first and adds a PyTorch primer. For everyone else, start with Deep Learning with PyTorch or D2L, then build the LLM. That path covers the library, the theory and a current model in two books.

Keep reading

Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) AI Ollama Models Cheat Sheet: Best Models by VRAM, Tested (PDF) Open Source LLM Comparison Table (2026) AI Open Source LLM Comparison Table (2026) Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) AI Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) Claude Code Plugins: Install, Manage and Pick Official Plugins AI Claude Code Plugins: Install, Manage and Pick Official Plugins GPT-6.1 Sol, Terra and Luna: Benchmarks, Pricing and Tests AI GPT-6.1 Sol, Terra and Luna: Benchmarks, Pricing and Tests Can AI Predict and Prevent Criminal Activity? AI Can AI Predict and Prevent Criminal Activity?

Leave a Comment

Press ESC to close