欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 产业 > nccl 03 记 回顾:从下载,编译到调试 nccl-test

nccl 03 记 回顾:从下载,编译到调试 nccl-test

2024/10/23 3:54:15 来源:https://blog.csdn.net/eloudy/article/details/139815842  浏览:    关键词:nccl 03 记 回顾:从下载,编译到调试 nccl-test

1, 下载与编译

1.1  源码下载


 

$ git clone  https://github.com/NVIDIA/nccl.git

1.2  编译

1.2.1 一般编译:
 

$ make -j src.build


1.2.2 特定架构gpu 编译
 

$ make -j src.build NVCC_GENCODE="-gencode=arch=compute_80,code=sm_80"

A100系列的为 sm_80;

1.2.3 只 debug 编译Host C++代码

<1> 修改 nccl/makefiles/common.mk

$ git diff
diff --git a/makefiles/common.mk b/makefiles/common.mk
index a037cf3..5540099 100644
--- a/makefiles/common.mk
+++ b/makefiles/common.mk
@@ -80,7 +80,8 @@ NVLDFLAGS   += ${GCOV_FLAGS:%=-Xcompiler %}ifeq ($(DEBUG), 0)NVCUFLAGS += -O3
-CXXFLAGS  += -O3 -g
+#LL:: CXXFLAGS  += -O3 -g
+CXXFLAGS  += -g -ggdb3elseNVCUFLAGS += -O0 -G -gCXXFLAGS  += -O0 -g -ggdb3

 为了debug 主机代码,修改 makefile相关代码的截图效果:

<2> 编译如上

$ make -j src.build NVCC_GENCODE="-gencode=arch=compute_80,code=sm_80"

1.2.4  全部编译为 debug 版本

$ make -j src.build NVCC_GENCODE="-gencode=arch=compute_80,code=sm_80" DEBUG=1 VERBOSE=1

$ make -j src.build NVCC_GENCODE="-gencode=arch=compute_80,code=sm_80" DEBUG=1

1.3 正式安装

(为了开发nccl本身的话,也可以不安装)

ubuntu:

$ # Install tools to create debian packages
$ sudo apt install build-essential devscripts debhelper fakeroot
$ # Build NCCL deb package
$ make pkg.debian.build
$ ls build/pkg/deb/

{

然后可以跟安装一般的deb包一样安装:

sudo dpkg -i /path/to/package.deb

如果出现依赖缺少问题,使用这个修复:

  sudo apt-get install -f

或者直接用apt来安装 deb 包:

   sudo apt install ./path/to/package.deb

}

2,验证示例代码

2.1 下载测试

将 nccl-test/ 下载到与 nccl/ 并列

$ git clone --recursive  https://github.com/NVIDIA/nccl-tests.git

$ ls

2.2 直接链接 nccl 编译 nccl-test

2.1 一般编译

$ cd nccl-test/
$ make  NCCL_HOME=../nccl/build

运行示例:

设置环境变量:

export LD_LIBRARY_PATH=../../nccl/build/lib

 此处存储了生成的 链接库:

运行:

2.2 Debug 编译 nccl-test

只debug 主机代码

2.2.1 修改Makefile信息

git diff 结果如下:

nccl-tests/src$ git diff
diff --git a/src/Makefile b/src/Makefile
index 393de8e..d704ccd 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -42,7 +42,8 @@ NVLDFLAGS  := -L${CUDA_LIB} -l${CUDARTLIB} -lrtifeq ($(DEBUG), 0)NVCUFLAGS += -O3 -g
-CXXFLAGS  += -O3 -g
+CXXFLAGS  += -O0 -g -ggdb3
+#LL:: CXXFLAGS  += -O3 -gelseNVCUFLAGS += -O0 -G -gCXXFLAGS  += -O0 -g -ggdb3

2.2.2 编译

$ make -j

同样elf文件在 nccl-test/build/ 中:

$ gdb ./all_gather_perf

进入gdb debug中:

先回顾到这里吧,明天继续...

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com