Ubuntu及Cuda的安装

注意:路径改为自己的路径

报错:

E:无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系

http://www.cnblogs.com/LeoGodfrey/p/3316834.html

1. 安装ubuntu,密码设置处选择自动登陆(不然会卡死在登陆界面-针对双显卡)

2. 进系统,软件和更新里安装驱动,装完不要点开;点关机或重启,可能会卡死,强制关机,重新进应该就不卡了

3. 安装python
https://www.cnblogs.com/luckyalan/p/6703590.html

sudo apt-get install python2.7 python2.7-dev
sudo apt-get install build-essential libssl-dev libevent-dev libjpeg-dev libxml2-dev libxslt-dev
sudo apt-get install python-pip

4. 安装torch

pip install '/home/hyafinthus/desktop/CUDA/torch-0.3.0.post4-cp27-cp27mu-linux_x86_64.whl'
pip install torchvision
pip install pandas

5. 降级安装gcc6
https://bbs.deepin.org/forum.php?mod=viewthread&tid=159308

sudo apt-get install gcc-6
sudo apt-get install g++-6
sudo rm -rf /usr/bin/gcc
sudo ln -s /usr/bin/gcc-6 /usr/bin/gcc
sudo rm -rf /usr/bin/g++
sudo ln -s /usr/bin/g++-6 /usr/bin/g++

6. 安装依赖项
https://blog.csdn.net/qjk19940101/article/details/78927109

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev

7. 安装cuda

sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
sudo apt-get update
sudo sh '/home/hyafinthus/desktop/CUDA/cuda_9.0.176_384.81_linux.run'

除了nvidia驱动选n其他选y,路径使用默认路径

8. 安装依赖项

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

9. 配置环境变量

export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

10. 安装cudnn

sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb 

11. 测试

nvcc -V
python
import torch
torch.cuda.is_available()

你可能感兴趣的:(Ubuntu及Cuda的安装)