当前位置:   article > 正文

torch安装_记Ubuntu 18.04上Torch7+CUDA 10.0安装过程

ubuntu18.04安装torch7

0de1657cebb37181c1c5f7e91355c8ba.png

(记录于2019.01.17,该解决方案并不一定支持旧版本或更新版本)

条件:Ubuntu 18.04系统、CUDA 10.0已安装。

过程:依照Torch7官方指引(Torch | Getting started with Torch),在目标安装目录下依次运行:

  1. $ git clone https://github.com/torch/distro.git ~/torch --recursive
  2. $ cd ~/torch
  3. $ bash install-deps
  4. $ ./install.sh

1)运行(如果没有安装git先安装)

  1. $ git clone https://github.com/torch/distro.git ~/torch --recursive
  2. $ cd ~/torch

2)依据 ubuntu18.04安装torch 遇到的几个Error处理

  • 2.1)修改文件install-deps,将sudo apt-get install -y python-software-properties替换成sudo apt-get install -y software-properties-common
  • 2.2)运行
$ git config --global url."https://".insteadOf git://

3)运行

$ bash install-deps

4)依据 Fails to build against CUDA 10 · Issue #834 · torch/cutorch

  • 4.1)Remove FindCUDA.cmake
  1. $ cd ~/torch
  2. $ rm -fr cmake/3.6/Modules/FindCUDA*
  • 4.2)在extra/cutorch中新建文件atomic.patch并添加内容:
  1. diff --git a/lib/THC/THCAtomics.cuh b/lib/THC/THCAtomics.cuh
  2. index 400875c..ccb7a1c 100644
  3. --- a/lib/THC/THCAtomics.cuh
  4. +++ b/lib/THC/THCAtomics.cuh
  5. @@ -94,6 +94,7 @@ static inline __device__ void atomicAdd(long *address, long val) {
  6. }
  7. #ifdef CUDA_HALF_TENSOR
  8. +#if !(__CUDA_ARCH__ >= 700 || !defined(__CUDA_ARCH__) )
  9. static inline __device__ void atomicAdd(half *address, half val) {
  10. unsigned int * address_as_ui =
  11. (unsigned int *) ((char *)address - ((size_t)address & 2));
  12. @@ -117,6 +118,7 @@ static inline __device__ void atomicAdd(half *address, half val) {
  13. } while (assumed != old);
  14. }
  15. #endif
  16. +#endif

然后运行

  1. $ cd extra/cutorch
  2. $ patch -p1 < atomic.patch
  3. $ export TORCH_NVCC_FLAGS="-D__CUDA_NO_HALF_OPERATORS__"

5)运行

  1. $ ./install.sh
  2. $ cd ~
  3. $ source .bashrc

6)根据需要安装其他包,如:

luarocks install nn
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/937052
推荐阅读
相关标签
  

闽ICP备14008679号