How to do hardware accelerated encoding through NVIDIA ?

I am using NVIDIA Encoder sample given in Video Codec SDK,but i am unable to encode RGB stream into h264 and the sample given in sdk is only for yuv input. There is any way to do it?

Read the latest Video SDK docs. RGB input is supported. You just have to set the right parameters, etc.