---
title: 获取子仓依赖时失败的解决办法
description: "获取子仓依赖时提示fatal: clone of 'xxx' into submodule path 'xxx' failed。详细信息如下："
url: https://www.hikunpeng.com/document/detail/zh/SRA/ecosystemEnable/PyTorch/kunpengpytorch_02_0020.html
sourcePath: /source/zh/SRA/ecosystemEnable/PyTorch/kunpengpytorch_02_0020.html
indexId: dbddb0c040bb8a332bccf8f5dc5fa6ae6cd97a67fdefdc5547b89af0a984fabe66
---
# 获取子仓依赖时失败的解决办法

#### 问题现象描述

获取子仓依赖时提示fatal: clone of 'xxx' into submodule path 'xxx' failed。详细信息如下：

```
Cloning into '/path/to/pytorch/third_party/cub'...
error: RPC failed; curl 18 transfer closed with outstanding read data remaining error: 1501 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet fatal: early EOF
fatal: fetch-pack: invalid index-pack output
fatal: clone of 'https://github.com/NVlabs/cub.git' into submodule path '/home/pytorch/third_party/cub' failed
Failed to clone 'third party/cub'. Retry scheduled
```

或

```
fatal: unable to access 'https://gitlab.com/libeigen/eigen.git/': error:1408F10B:SSL routines:ssl3_get_record:wrong version number
fatal: clone of 'https://gitlab.com/libeigen/eigen.git' into submodule path '/home/pytorch/third_party/eigen' failed
```


#### 关键过程、根本原因分析

网络不稳定导致子仓下载失败。


#### 结论、解决方案及效果

方法一

进入“path/to/pytorch”目录，重新获取子仓。

```
cd /path/to/pytorch
git submodule update --init --recursive
```

方法二

若方法一无法成功获取到子仓，可手动下载依赖，上传到服务器，并通过以下命令重新指定子仓本地目录路径。下文以eigen子仓为例：

1. 用一台可以访问https://gitlab.com/libeigen/eigen.git的机器执行以下命令拉取代码。
  1 git clone https://gitlab.com/libeigen/eigen.git

2. 将下载的代码上传到服务器的“/path/to/eigen”路径下。
3. 进入“pytorch”目录查询子仓模块名。
  1 2 cd /path/to/pytorch cat .gitmodules | grep eigen

  查询结果如下，其中，third_party/eigen为模块名。

```
[submodule "third_party/eigen"]
path = third_party/eigen
url = https://gitlab.com/libeigen/eigen.git
```


4. 指定“third_party/eigen”模块的submodule本地路径。
  1 git config submodule.third_party/eigen.url /path/to/eigen

5. 重新获取子仓。
  1 git submodule update --init --recursive
