Complex computations typically occur via the composition of modular units, such as the universal logic gates found in logical circuits. The benefit of modular information processing, in contrast to globally integrated information processing, is that complex global information processing is more easily and flexibly implemented via a series of simpler, localized information processing operations that only control and change local degrees of freedom. We show that, despite these benefits, there are unavoidable thermodynamic costs to modularity-costs that arise directly from the operation of localized processing and that go beyond Landauer's dissipation bound for erasing information. We quantify the minimum irretrievable dissipation of modular computations in terms of the difference between the change in global nonequilibrium free energy and the local (marginal) change in nonequilibrium free energy, which bounds modular work production. This modularity dissipation is proportional to the amount of additional work required to perform the computational task modularly, measuring a structural energy cost. It determines the thermodynamic efficiency of different modular implementations of the same computation, and so it has immediate consequences for the architecture of physically embedded transducers, which are information processing agents. Constructively, we show how to circumvent modularity dissipation by designing agents that capture the information reservoir's global correlations and patterns. We prove that these agents, when acting as pattern generators or extractors, must match the complexity of their environment to minimize the modularity dissipation. Thus, there are routes to thermodynamic efficiency by optimizing the modular architecture of computations.