  We define Hochschild cohomology of the second kind for differential graded
(dg) or curved algebras as a derived functor in a compactly generated derived
category of the second kind, and show that it is invariant under Morita
equivalence of the second kind. A bimodule version of Koszul duality is
constructed and used to show that Hochschild cohomology of the second kind is
preserved under (nonconilpotent) Koszul duality. Hochschild cohomology of the
second kind of an algebra often computes the ordinary Hochschild cohomology of
geometrically meaningful dg categories. Examples include the category of
infinity local systems on a topological space, the bounded derived category of
a complex algebraic manifold and the category of matrix factorizations.
