In this paper, we study the performance of cognitive amplify-and-forward (AF) relay networks where the secondary users opportunistically access M licensed bands of the primary users over Nakagami-m fading channels. In order to enhance the accuracy of spectrum sensing and strongly protect the primary users from being interfered by the secondary transmission, collaborative spectrum sensing is deployed among the secondary transmitter, secondary relay, and secondary receiver. In particular, an analytical expression for the capacity of the considered network is derived. Numerical results are provided to show the influence of the arrival rate of the primary users on the channel utilization of licensed bands. Finally, the impact of the number of the licensed bands, channel utilization of the primary users, false alarm probability, and transmission distances on the capacity of the considered system are investigated.