前面我们已经在windows10环境下成功安装了CPU版本的Pytorch,推荐的是利用Anaconda安装。
经过接近一天的奋战,博主成功在linux系统安装GPU加速的pytorch,博主使用的发行版是Ubuntu18.04。
说一下CUDA和CUDNN都是啥吧。
CUDA(Compute Unified Device Architecture),是英伟达公司推出的一种基于新的并行编程模型和指令集架构的通用计算架构,它能利用英伟达GPU的并行计算引擎,比CPU更高效的解决许多复杂计算任务。
CUDNN是用于深度神经网络的GPU加速库。
具体参考博客:
https://blog.youkuaiyun.com/qq_28660035/article/details/80959752
https://blog.youkuaiyun.com/fangjin_kl/article/details/53906874
一、安装Anaconda
linux下安装Anaconda很简单,步骤和前一篇在windows下安装的步骤相似。
1.下载Anaconda
这个过程就不重新说一遍了,还是老话,去镜像源下载,去镜像源下载,去镜像源下载,因为官网太慢了!然后选择的版本是linux下的,根据自己的电脑操作位数选择32还是64位。
镜像下载地址和修改方法参考前一篇博客:https://blog.youkuaiyun.com/wuzhiwuweisun/article/details/82689151
这里我下载的是Anaconda3-5.0.1-Linux-x86_64.sh,自带的python的版本是3.6。百度云链接还有一个Anaconda是3.4.3的,自带的python版本是3.5的。
这里贴一下百度云的链接:链接:https://pan.baidu.com/s/15N7KdtxkChOH7WsMaC_IJQ 提取码:286y
2.安装Anaconda
这个比windows简单,一条命令。
首先切换到anaconda安装包的路径,在该路径下执行指令:
sh Anaconda3-5.0.1-Linux-x86_64.sh #后边的文件名称是你的安装包的名称
后边的话就很简单了。
Welcome to Anaconda3 5.0.1
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>> 按回车
#然后一直按回车到协议完毕
#出现:
Do you accept the license terms? [yes|no]
>>>输入yes
#下面就是问你安装目录,建议就是默认的安装路径,直接按回车
Anaconda3 will now be installed into this location:
/home/mayunteng/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/mayunteng/anaconda3] >>> 按回车
#接下来就是等待安装完成
#注意安装完成以后会询问你是否把anaconda3的路径加到环境变量里去,一定要选yes,一定要选yes,一定要选yes。
安装完成以后,重启终端,依次输入下面的指令,如果显示的是anaconda版本的python,代表安装成功。
先输入:source ~/.bashrc
再输入:python
显示的python版本后面有Anaconda标识,代表安装成功
Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
#退出python的命令交互行输入exit()回车就可以了。
我们也可以输入conda list 查看安装的库。
输入:conda list
显示(已经安装好的库):
# packages in environment at /home/mayunteng/anaconda3:
#
# Name Version Build Channel
_ipyw_jlab_nb_ext_conf 0.1.0 py36he11e457_0 defaults
alabaster 0.7.10 py36h306e16b_0 defaults
anaconda 5.0.1 py36hd30a520_1 defaults
anaconda-client 1.6.5 py36h19c0dcd_0 defaults
anaconda-navigator 1.6.9 py36h11ddaaa_0 defaults
anaconda-project 0.8.0 py36h29abdf5_0 defaults
asn1crypto 0.22.0 py36h265ca7c_1 defaults
astroid 1.5.3 py36hbdb9df2_0 defaults
astropy 2.0.2 py36ha51211e_4 defaults
babel 2.5.0 py36h7d14adf_0 defaults
backports 1.0 py36hfa02d7e_1 defaults
b