Moved cuda resource mapping to we only map resource once. This is much faster.