Cannot login after installing Cuda on ubuntu

I have ubuntu 14.04 on my laptop.
Model : ideapad z50-70 lenovo
Cpu/Gpu : i7 4510u / Geforce 840m 4GB

I am trying to install cuda c 7.5 (although same problem occurs in cuda 7.0)

When i switch off my lightdm and then start it, it working normally.
But when i switch it off and run the .run provided on the download page, and then start lightdm, i get stuck in the login screen.
I am able to login through text console but i login from gui interface, then the login screen appears again.
How can i fix this ?
I searched the internet and found that a lot of people are facing same problem and other people suggest to remove nvidia driver. I cannot do this as I want to work on cuda programming.

Have you tried another toolkit version, e.g. 6.5, or using the .deb package?

I had the same problem with the login screen, with a huge difference that my graphics card was not supported by 6.5 or 7.0. The only way to for me to get around the login screen, was to delete the nvidia toolkit completely:

sudo apt-get autoremove --purge nvidia-*

and to install the compatible driver directly from nvidia’s driver section.
The .run-file installer should ask if you want to install a driver.

At least it states this for the 6.5 release in the Q&A section and here

Q: Will the installer replace the driver currently installed on my system?
A: The installer will provide an option to install the included driver, and if selected, it will replace the driver currently on your system.

But I haven’t tested it myself.