Commissioning the CMS pixel detector with cosmic rays