CUDA 6.5 devicequery returns fail when using optirun


I am using a lenovo u410 thinkpad with optimus and have bumblebee and CUDA 6.5 installed. When I optirun glxspheres64 it correctly uses my GPU, but when I try to run the devicequery I always get fail, even when using optirun. Is there something I should be doing I am not? Or is something possibly wrong with my install?

I have solved this issue by setting the alternative to nvidia by running the command

sudo update-alternatives --config x86_64-linux-gnu_gl_conf

and selecting my nvidia driver.