毕设日志——pytorch版本faster rcnn运行代码前的环境配置2019.4.9

准备测试的代码是:

https://github.com/jwyang/faster-rcnn.pytorch
讲解:https://hellozhaozheng.github.io/z_post/PyTorch-FasterRCNN/


一、查看Ubuntu版本

  • 使用命令:lsb_release -a
    输出:
jingge@svr1:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS  # 我的版本16.04
Release:        16.04
Codename:       xenial

二、查看linux系统位数,以下载对应anaconda版本

  • 使用命令getconf LONG_BIT
    输出64
  • 或者使用命令uname -a
    输出
Linux svr1 4.4.0-91-generic #114-Ubuntu SMP Tue Aug 8 11:56:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
# x86_64说明我是64位内核, 跑的是64位的系统;
# i386, i686说明你是32位的内核, 跑的是32位的系统

三、anaconda下载安装

  • 想用python3.6版本,参考https://blog.csdn.net/yuejisuo1948/article/details/81043823
    准备下载Anaconda3-5.2.0

  • 关闭VPN,进入清华镜像源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

  • 选择Anaconda3-5.2.0-Linux-x86_64.sh,下载到自己的H盘下新建的Anaconda3-5.2.0文件夹中

  • 在自己下载的目录下,运行

bash Anaconda3-5.2.0-Linux-x86_64.sh

在这里插入图片描述

  • 一直enter直到出现Please answer 'yes' or 'no',输入yes
    在这里插入图片描述
  • 出现默认安装目录,确定按照它的默认/anaconda3,所以enter
    在这里插入图片描述
  • 安装中installing
    在这里插入图片描述
  • installation finished后,出现Do you with the installer to prepend the Anaconda3 install location to PATH in your /home/username/.bashrc?,输入yes
  • 出现Thank you for installing Anaconda3!
    在这里插入图片描述
  • anaconda安装完成
  • Do you wish to proceed with the installation of Microsoft VSCode?询问我是否装vscode,我选择yes安装,迅速完成提示installed
    在这里插入图片描述
  • 安装完成后 不要忘记输入
source  ~/.bashrc

(否则仍旧为Ubuntu默认的python2.7)

  • 再输入python -V,输出显示python 3.6.5:: Anaconda, Inc
    在这里插入图片描述

参考
https://blog.csdn.net/zaishijizhidian/article/details/81663387
https://blog.csdn.net/weixin_40294256/article/details/79555606


四、创建一个和已经装了的python3.6共存的python2.7的anaconda环境

  • 输入
 conda create -n py27 python=2.7

在这里插入图片描述

  • 以后在使用中
  • 使用source activate py27激活python2.7环境
    在这里插入图片描述
  • 使用source deactivate关闭python2.7环境
    在这里插入图片描述

五、查看CUDA和cudnn版本

  • 查看cuda 版本
  • CUDA 8.0.61
cat /usr/local/cuda/version.txt

在这里插入图片描述

  • 查看 CUDNN 版本
  • 5.1.10
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

在这里插入图片描述


六、安装配置pytorch

  • 参考

https://blog.csdn.net/leviopku/article/details/84548816

conda create -n py36pytorch python=3.6
  • 验证安装好了一个虚拟环境:
$ source activate py36pytorch
(py36pytorch) jingge@svr1:~$ python -V
Python 3.6.8 :: Anaconda, Inc.
  • 进入pytorch官网https://pytorch.org/get-started/locally/ 选择自己CUDA8.0,Linux,conda,stable,python3.6的配置,出现一个命令
conda install pytorch torchvision cudatoolkit=8.0 -c pytorch
  • 使用上述命令安装pytorch 0.4.0
  • 发现结果安装的不是自己想要的pytorch0.4.0:
    在这里插入图片描述
  • 卸载上面版本的pytorch:
conda uninstall pytorch
conda uninstall libtorch

今天get新技能:
① linux中用ls打开一个目录后,如何快速进入里面
使用cd 进入目录,输入想进入的目录的前几个字母,然后按tab键即可自动补全。
②从别处复制后,在putty软件中鼠标右键即可粘贴


明天终于可开始下载数据跑代码了,
记住数据放在hdd2T中!


2019.4.11修改

昨天发现作者的是基于python2.7编译的,为了保持一致除去不必要的麻烦,我之前的虚拟环境py36pytorch配置的是python3.6,需要重新配置一个python2.7的。在这个过程中,经历了以下麻烦:

  • 新建py27pytorch虚拟环境,在清华镜像源下载安装的pytorch,conda install 完成后import torch总是报错,pytorch安装不成功
  • 重新再之前建立了没用的py27环境中安装,一样的错误
  • 重装anaconda:
rm -rf anaconda3
bash Anaconda3-5.2.0-Linux-x86_64.sh
  • 没有用source ~/.bashrc命令,直接关闭终端重新开一个。
  • conda -V验证anaconda安装成功
    在这里插入图片描述
  • 新建名为pytorch的虚拟环境,配置python2.7
conda create -n pytorch python=2.7

在这里插入图片描述

  • 激活环境
conda activate pytorch

在这里插入图片描述

conda install pytorch torchvision cudatoolkit=8.0 -c pytorch

在这里插入图片描述

-下载完成,验证
在这里插入图片描述

import torch
torch.cuda.is_available() 
torch.__version__ # 重开终端后,似乎需要用source activate而不是conda activate 激活环境
  • 删除之前的不要的虚拟环境
conda env remove -n py27
conda env remove -n py27pytorch
conda env list

在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值