lammps 怎么编译gpu版本_pytorchgpu源码编译

软硬件环境

  • ubuntu 18.04 64bit
  • NVidia GTX 1070Ti
  • anaconda with python 3.7
  • CUDA 10.1
  • cuDNN 7.6
  • pytorch 1.8

python和gpu环境

这个就不多讲了,没装好的,可以参考下面的链接

  • anaconda基本使用
  • ubuntu安装CUDA和cuDNN

编译步骤

安装基础依赖

conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses

由于要使用gpu,所以还需要安装LAPACK支持,根据CUDA版本安装对应的软件包

# Add LAPACK support for the GPU if needed
conda install -c pytorch magma-cuda101  # or [ magma-cuda101 | magma-cuda100 | magma-cuda92 ] depending on your cuda version

接下来就可以开始克隆代码了

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive

准备工作完成后,就可以开始编译了

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
python setup.py install

CMAKE_PREFIX_PATH其实就是anaconda的安装目录,如我这里的/home/xugaoxiang/anaconda3

c62e96b15f4a9cc64ea101152ec3051f.png

pytorch

编译的时候较长,耐心等待就好

测试

重新开一个terminal进行测试

(base) xugaoxiang@1070Ti:~$ ipython
Python 3.7.6 (default, Jan  8 2020, 19:59:22)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import torch

In [2]: torch.__version__
Out[2]: '1.8.0a0+46d846f'

In [3]: torch.cuda.is_available()
Out[3]: True

In [4]:

说明pytorch已经安装到了anaconda的环境中,而且是gpu的版本,搞定!

小结

整个编译过程还是非常顺利的,之前我们编译过opencvtensorflowcaffe,跟他们相比,pytorch在依赖关系的处理上做的非常好,以子项目的形式纳入到自己的工程当中,整个编译过程没出现过报错,文档也是写的简单明了,难怪它的市占率会越来越高。

参考资料

  • https://github.com/pytorch/pytorch
  • https://xugaoxiang.com/2019/12/08/anaconda/
  • https://xugaoxiang.com/2019/12/13/ubuntu-cuda/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值