1. 程式人生 > 其它 >lammps 怎麼編譯gpu版本_pytorchgpu原始碼編譯

lammps 怎麼編譯gpu版本_pytorchgpu原始碼編譯

技術標籤:lammps 怎麼編譯gpu版本

軟硬體環境

  • 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

編譯步驟

安裝基礎依賴

condainstallnumpyninjapyyamlmklmkl-includesetuptoolscmakecffityping_extensionsfuturesixrequestsdataclasses

由於要使用gpu,所以還需要安裝LAPACK支援,根據CUDA版本安裝對應的軟體包

#AddLAPACKsupportfortheGPUifneeded
condainstall-cpytorchmagma-cuda101#or[magma-cuda101|magma-cuda100|magma-cuda92]dependingonyourcudaversion

接下來就可以開始克隆程式碼了

gitclone--recursivehttps://github.com/pytorch/pytorch
cdpytorch
#ifyouareupdatinganexistingcheckout
gitsubmodulesync
gitsubmoduleupdate--init--recursive

準備工作完成後,就可以開始編譯了

exportCMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname$(whichconda))/../"}
pythonsetup.pyinstall

CMAKE_PREFIX_PATH其實就是anaconda的安裝目錄,如我這裡的/home/xugaoxiang/anaconda3

c62e96b15f4a9cc64ea101152ec3051f.png

pytorch

編譯的時候較長,耐心等待就好

測試

重新開一個terminal進行測試

(base)[email protected]:~$ipython
Python3.7.6(default,Jan82020,19:59:22)
Type'copyright','credits'or'license'formoreinformation
IPython7.19.0--AnenhancedInteractivePython.Type'?'forhelp.

In[1]:importtorch

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/