Ubuntu安装PBG并提供GPU支持

Ubuntu安装PBG

硬件/软件配置

  • ubuntu 18.04
  • nvidia-smi 440.100

使用docker进行安装

可根据需求以root用户权限或以非root用户权限安装Pytorch和PBG。

  • 配置pip源
    cd ~
    mkdir .pip
    cd .pip
    touch pip.conf
    echo "[global]" >> ~/.pip/pip.conf
    echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> ~/.pip/pip.conf
    echo "[install]" >> ~/.pip/pip.conf
    echo "trusted-host = https://pypi.tuna.tsinghua.edu.cn" >> ~/.pip/pip.conf
    cd /home/MyWorkspace
    
  • 根据驱动满足的最大cuda版本来查找合适版本的pytorch,不需要单独安装cuda
  • 下载PBG源码进行编译安装,不需要单独安装cuda
    wget https://github.com/facebookresearch/PyTorch-BigGraph/archive/refs/heads/main.zip
    unzip main.zip
    rm main.zip
    cd PyTorch-BigGraph-main
    PBG_INSTALL_CPP=1 pip install .
    

    若不使用GPU,则可以使用pip install .进行安装
    根据需要,使用PBG提供的案例mv torchbiggraph/examples ../pbg-examples和删除安装包cd .. && rm -rf PyTorch-BigGraph-main
    PBG的python库和可执行命令分别被安装在**/site-packages**/bin中。

使用Docker进行部署PBG

  • 打包镜像
    sudo docker commit -m "pip install pbg with cuda:10.2 and pytorch:1.12.0" container_id pbg_single:v1.0
    
  • 编写docker-compose.yml以部署单个容器
    version: '3'
    services:
    	dgl_cluster:
    		image: pbg_single:v1.0
            user: "pbg"
            working_dir: /home/pbg/MyWorkspace
            volumes:
            	- ./pbg:/home/pbg/MyWorkspace
            shm_size: '32g'
            storage_opt:
            	size: '256g'
            deploy:
            	resources:
            	    limits:
              			cpus: '8.0'
              			memory: 16G
            		reservations:
            			devices:
            				- driver: nvidia
            				  count: "all"
            				  capabilities: [gpu]
            stdin_open: true
            tty: true
            command: /bin/bash -c "/bin/bash /home/pbg/.ssh/sshd.sh && /bin/bash"
    
  • 使用docker-compose部署容器
    sudo docker-compose up -d
    

使用Docker部署分布式PBG

使用Docker部署DistDGL

  • 安装sshd并配置ssh(在安装PBG之前或之后均可)
  • 打包镜像
    sudo docker commit -m "pip install pbg with cuda:10.2 and pytorch:1.12.0 and sshd" container_id pbg_single:v1.0
    
  • 部署单个容器
    version: '3.5'
    services:
    	pbg_cluster:
    		image: pbg_single:v1.0
            user: "pbg"
            working_dir: /home/pbg/MyWorkspace
            volumes:
            	- ./pbg:/home/pbg/MyWorkspace
            shm_size: '32g'
            storage_opt:
            	size: '256g'
            deploy:
            	resources:
            	    limits:
              			cpus: '8.0'
              			memory: 16G
            		reservations:
            			devices:
            				- driver: nvidia
            				  count: "all"
            				  capabilities: [gpu]
            stdin_open: true
            tty: true
            command: /bin/bash -c "/bin/bash /home/pbg/.ssh/sshd.sh && /bin/bash"
    
  • 部署多个镜像
    sudo docker-compose up --scale pbg_cluster=2 -d
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值