美文网首页
install pytorch cuda总结坑

install pytorch cuda总结坑

作者: 水星no1 | 来源:发表于2019-04-21 17:22 被阅读0次

环境ubuntu 18.10
nvidia Geforce 1080ti
python3.7
cuda10

1. 安装nvidia驱动

选择安装型号:https://www.nvidia.com/Download/driverResults.aspx/145182/en-us
官网:https://www.nvidia.com/Download/index.aspx?lang=cn
wget后
sudo chmod +x cuda****-run
sudo ./cuda****-run
sudo reboot
开机出现错误:started bpfilter, 一直无法进入系统
解决参考:

sudo apt-get install xdm
sudo dpkg-reconfigure lightdm

也删了这个:sudo apt-get remove --purge nvidia-*

2. 安装torch

2.1 conda 安装

失败,官方源太慢,卡住了,清华的源2019.4.16停止服务,转pip安装


image.png
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

查看~/.condarc

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true

defaults是官方默认的源
conda info 查看是否生效

2.2 pip安装

国内网速的问题,我们直接pip安装包通常速度非常慢,而且经常会出现装到一半失败了的问题,既然这样,我们就要充分利用国内镜像的力量,节省时间,明显提高pip安装的效率

  • 安装python3.7环境
    apt-get install python3.7-dev
  • 更换pip源
    更换pip源方法1
    pip install pygame -i http://pypi.douban.com/simple
    or
    pip install pygame -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
    更换pip源方法2
    sudo gedit ~/.pip/pip.conf,添加以下内容
[global] 
index-url = [http://pypi.douban.com/simple](http://pypi.douban.com/simple) 
[install] 
trusted-host=pypi.douban.com

豆瓣(douban) http://pypi.douban.com/simple/
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

  • 查看pip指向
    pip3 -V
    修改为python3.7
    which pip
    编辑pip文件:
    vim /usr/local/bin/pip 修改第一行就好
    确认pip3使用的是python3.7

  • 安装torch
    根据官网提示安装:https://pytorch.org/get-started

pip3 install https://download.pytorch.org/whl/cu100/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
pip3 install torchvision

查看显卡使用情况

Linux查看Nvidia显卡信息及使用情况
Nvidia自带一个命令行工具可以查看显存的使用情况:
nvidia-smi

image.png
表头释义:

Fan:显示风扇转速,数值在0到100%之间,是计算机的期望转速,如果计算机不是通过风扇冷却或者风扇坏了,显示出来就是N/A;
Temp:显卡内部的温度,单位是摄氏度;
Perf:表征性能状态,从P0到P12,P0表示最大性能,P12表示状态最小性能;
Pwr:能耗表示;
Bus-Id:涉及GPU总线的相关信息;
Disp.A:是Display Active的意思,表示GPU的显示是否初始化;
Memory Usage:显存的使用率;
Volatile GPU-Util:浮动的GPU利用率;
Compute M:计算模式;

ref:
https://blog.csdn.net/yucicheung/article/details/79094657#2%E4%BF%AE%E6%94%B9conda%E9%95%9C%E5%83%8F%E6%BA%90
https://blog.csdn.net/dcrmg/article/details/78146797

相关文章

网友评论

      本文标题:install pytorch cuda总结坑

      本文链接:https://www.haomeiwen.com/subject/zbjjgqtx.html