Unable to install cuda 8.0 properly in optimus windows 10 laptop

I am unable to run cuda samples properly. Whenever I run oceanFFT.exe it gives output as below,

CUDA error at C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\inc\helper_cuda.h:1133 code=38(cudaErrorNoDevice) “cudaGetDeviceCount(&device_count)”

My laptop is having optimus enabled with gpu (NVIDIA GeForce 940MX and Intel HD Graphics 640) and Windows 10. I have installed Visual Studio 2015 Community with update 3 and then installed Cuda 8.0. I am not facing any problem to build the binaries of cuda examples by using VS. Sometimes I am able to run the binaries but most of the time I fail to run it and getting above errors. Even though I have updated the gpu driver Geforce 940MX still I am getting the same error. Please help me to resolve the issue.

read up on optimus:

http://nvidia.custhelp.com/app/answers/detail/a_id/2615/~/how-do-i-customize-optimus-profiles-and-settings%3F

http://docs.nvidia.com/cuda/optimus-developer-guide/index.html

create a profile that forces the use of your dGPU. Run your CUDA codes under that profile.

I have gone through the material vividly but unable to setup it properly and could not create a profile in NVIDIA control panel. It is unfortunate that I could not find nvidia control panel when right click on my desktop. I found nvidia control panel in control panel page. However it is not opening, It is telling that NVIDIA display settings are not available. You are not currently using a display attached to an NVIDIA GPU.
Please help me.