码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Fastmoe安装


    Fastmoe安装

    名称ubuntucudatorchnccl
    版本18.0410.2torch-1.8.0-cp37-cp37m2.7.8

    1、安装虚拟环境

    1. #创建虚拟环境
    2. (base) root@9fd4db53dc92:~# conda create -n torch-1.8-cu102-py37 python=3.7
    3. #进入虚拟环境
    4. (base) root@9fd4db53dc92:~# conda activate torch-1.8-cu102-py37

    2、NCCL安装

    2.1 确认此pytorch支持的nccl版本

    1. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# ipython
    2. Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21)
    3. Type 'copyright', 'credits' or 'license' for more information
    4. IPython 7.34.0 -- An enhanced Interactive Python. Type '?' for help.
    5. In [1]: import torch
    6. In [2]: torch.cuda.nccl.version()
    7. Out[2]: 2708

    2.2 安装2.7.8版本的nccl

    nccl下载链接:https://developer.nvidia.com/nccl/nccl-legacy-downloadsimage.png-197.5kB

    2.2.1 安装依赖包

    (torch-1.8-cu102-py37) root@9fd4db53dc92:~# apt-get install -y gnupg2

    2.2.2 添加key

    1. #下载key
    2. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# wget https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
    3. #添加key
    4. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# apt-key add 7fa2af80.pub
    5. OK

    2.2.3 安装储存库资源

    1. #下载储存库资源
    2. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
    3. #安装储存库资源
    4. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# dpkg -i nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb

    2.2.4 更新

    (torch-1.8-cu102-py37) root@9fd4db53dc92:~# apt-get update

    2.2.5 安装 libnccl2 libnccl-dev

    (torch-1.8-cu102-py37) root@9fd4db53dc92:~# apt install libnccl2=2.7.8-1+cuda10.2 libnccl-dev=2.7.8-1+cuda10.2

    2.2.6 配置环境变量

    1. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# vim ~/.bashrc
    2. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# tail -3 ~/.bashrc
    3. export PATH=$PATH:/usr/local/cuda-10.2/bin
    4. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.2/lib64
    5. export CUDA_HOME=/usr/local/cuda-10.2
    6. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# source ~/.bashrc

    3、编译fastmoe 1.0

    3.1 通过release下载的源码

    默认的仓库是master分支,我选择了release分支里的1.0版本代码安装,会更稳一点

    3.2 排坑

    1. cuda/fastermoe/smart_schedule.h: In function ‘void fmoe_cuda_fused_forward_impl(pybind11::function, pybind11::function, pybind11::function, c10::Device, std::vector<at::Tensor>, scalar_t*, scalar_t*, scalar_t*, scalar_t*, const long int*, const long int*, const bool*, long int, long int, long int, long int, long int, long int, CudaStreamManager*)’:
    2. cuda/fastermoe/smart_schedule.h:169:61: error: too few arguments to function ‘cudaError_t cudaStreamWaitEvent(cudaStream_t, cudaEvent_t, unsigned int)’
    3. cudaStreamWaitEvent(smgr->stream(1), evt_get);
    1. cuda/fastermoe/smart_schedule.h:39:9: note: in definition of macro ‘GEN_IDX’
    2. int gidx_recv = ei * world_size + rank_recv; \
    3. ^~~~~~~~~
    4. error: command '/usr/bin/gcc' failed with exit code 1

    官网上说默认没开启nccl,但实际他的安装过程是开启的image.png-96.7kB

    只有关闭nccl才能通过编译安装,否则报错

    1. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# export USE_NCCL=0
    2. (torch-1.8-cu102-py37) root@9fd4db53dc92:~# cd moe_5.31/
    3. (torch-1.8-cu102-py37) root@9fd4db53dc92:~/moe_5.31# python setup.py install

    3.3 验证

    440595383651e6ab31c0efd8ec68786.png-73.7kB

    4、附录

    以下是编译过程中一些排错过程

    https://stackoverflow.com/questions/11094718/error-command-gcc-failed-with-exit-status-1-while-installing-eventlet

    https://linuxtect.com/the-error-command-gcc-failed-with-exit-status-1-error-and-solution/

    https://www.cnblogs.com/gerrydeng/p/7159021.html

    https://itsmycode.com/error-command-errored-out-with-exit-status-1/

    https://qiita.com/picato1123/items/eb8405b1c98de06e628e

    https://computerverge.com/error-message-error-command-gcc-failed-with-exit-status-1-causes-and-fixes/

  • 相关阅读:
    疫苗预约系统,疫苗接种管理系统,疫苗预约管理系统毕设作品
    基于SSM和Web实现的农作物生长监控系统
    vue3使用Swiper实现简单轮播图
    【教师资格证考试综合素质——法律专项】教育法笔记以及练习题
    交换两个数值(不用第三个变量
    【JavaEE初阶】多线程 _ 进阶篇 _ 锁的优化、JUC的常用类、线程安全的集合类
    桐乡上元——UI设计
    聊聊二叉树的前序遍历算法
    小米华为,化干戈为玉帛!
    npm发布自己的插件包:新手教程
  • 原文地址:https://blog.csdn.net/weixin_43279138/article/details/125619377
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号