Good question, lukebuz.
The general rule is that "[
t]here shall be allowed as a deduction any loss sustained during the taxable year and not compensated for by insurance or otherwise". 26 USC § 165(a). However, in the case of individuals, deductions for losses are allowed only if the loss is of the sort described in 26 USC § 165(c). This includes (as relevant here) "losses incurred in any transaction entered into for profit". 26 USC § 165(c)(2).
The Secretary of the Treasury has prescribed a regulation that describes under what circumstances and to what extent the loss on your house sale constitutes such a transaction.
26 CFR 1.165-9(b). According to this regulation, when calculating the potentially deductible loss on the sale, the basis of the property is adjusted downward to "[
t]he fair market value of the property at the time [that you started renting out the property]", if that is lower than what the basis would otherwise be. 26 CFR 1.165-9(b)(2)(i).
The consequence of this regulation is that, as far as losses go, when you change your property from your residence to a rental property, you in effect "lock in" the unrealised loss and no deduction for it is ever possible. You can only potentially deduct any
further losses that occur after you start using the property as a rental.