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

0de1657cebb37181c1c5f7e91355c8ba.png

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

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

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

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

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

$ git clone https://github.com/torch/distro.git ~/torch --recursive
$ 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
$ cd ~/torch
$ rm -fr cmake/3.6/Modules/FindCUDA*
  • 4.2)在extra/cutorch中新建文件atomic.patch并添加内容:
diff --git a/lib/THC/THCAtomics.cuh b/lib/THC/THCAtomics.cuh
index 400875c..ccb7a1c 100644
--- a/lib/THC/THCAtomics.cuh
+++ b/lib/THC/THCAtomics.cuh
@@ -94,6 +94,7 @@ static inline __device__ void atomicAdd(long *address, long val) {
 }
 
 #ifdef CUDA_HALF_TENSOR
+#if !(__CUDA_ARCH__ >= 700 || !defined(__CUDA_ARCH__) )
 static inline  __device__ void atomicAdd(half *address, half val) {
   unsigned int * address_as_ui =
       (unsigned int *) ((char *)address - ((size_t)address & 2));
@@ -117,6 +118,7 @@ static inline  __device__ void atomicAdd(half *address, half val) {
    } while (assumed != old);
 }
 #endif
+#endif

然后运行

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

5)运行

$ ./install.sh
$ cd ~
$ source .bashrc

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

luarocks install nn
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值