If you can only work with Ubuntu14.04, you can check 赵博雅's answer, somehow you may have some future problem to figure out.
For me, I reinstalled Ubuntu 16.04 which makes everything easier, here is the installation step you can follow . If you have any question, you can comment to let me know.
Nvidia driver and Cuda installation:
1. sudo apt-get update
2. sudo apt-get upgrade
3. sudo apt-get dist-upgrade
4. Additional drivers
Nvidia X server setting
5. Download cuda_7.5.18_linux.run
6. ./cuda_7.15.18_linux.run
7. ./cuda_7.15.18_linux.run --override
8. cd NVIDIA_CUDA-7.5_Samples/
9. cd 0_Simple/clock
10. make ##### This may have error
11. sudo apt-get install gcc-4.9
12. gcc -- version
whereis gcc
cd /usr/bin
ls -lad gcc*
ln -s gcc-4.9 gcc
sudo rm gcc
sudo ln -s gcc-4.9 gcc
sudo rm gcc-ar
sudo ln -s gcc-ar-4.9 gcc-ar
sudo rm gcc-nm
sudo ln -s gcc-nm-4.9 gcc-nm
sudo rm gcc-ranlib
sudo ln -s gcc-ranlib-4.9 gcc-ranlib
ls -lad gcc*
gcc --version
13. which g++
cd /usr/bin
ls -lad g+*
sudo apt-get install g++-4.9
sudo rm g++
sudo ln -s g++-4.9 g++
14. cd ~/NVIDIA_CUDA-7.5_Samples/
cd 0_Simple/clock
make ./ clock
----------------------------My Previous Answer-----------------------------------------------------------------------------
经历了各种配置,给后人留个完整帖子,可以少走弯路。配置环境是ubuntu14.04系统,显卡是Nvidia GeoForce GTX970m, cuda安装的是7.5版本,步骤主要参考以下链接(很重要的一点是安装nvidia gpu driver要先于安装cuda!)
http://blog.csdn.net/xuezhisdc/article/details/47075401
cuda 安装是根据这个装的网络deb版本Installing CUDA Toolkit 7.5 on Ubuntu 14.04 Linux
如果你很不幸的进不了Ubuntu GUI界面,就按ctrl+shift+F1进入命令行界面,然后输入以下命令先停掉lightdm,然后安装gdm(把gdm设置为默认开启模式)再重启一下电脑就进了。
sudo stop lightdmsudo apt-get install gdm
###################################################
一般情况下,上面可能还不行,你需要再执行以下这两个tutorial。
再按CTRL+ALT+F1
sudo apt-get udpate
sudo apt-get install nvidia-current-updates
sudo nvidia-xconfig
sudo reboot