# DGL ## 安装 安装DGL,你需要 + dtk 22.10 + Python 3.9 其余版本需源码安装 ### 使用pip安装 dgl whl包下载目录:[https://cancon.hpccube.com:65024/4/main/dgl/dtk22.10](https://cancon.hpccube.com:65024/4/main/dgl/dtk22.10) ```shell pip install dgl* (下载的dgl的whl包) ``` ### 使用源码安装 #### 编译环境准备 ```shell pip install setuptools==59.5.0 wheel ``` #### 编译安装 ```shell git clone -b 0.9.1-dgl https://developer.hpccube.com/codes/aicomponent/dgl cd dgl mkdir build && cd build source $ROCM_PATH/env.sh cmake -DUSE_HIP=ON -DCMAKE_BUILD_TYPE=Release .. make -j16 cd ../python python setup.py bdist_wheel pip install dist/dgl* ``` ## 参考 - [README_ORIGIN](README_ORIGIN.md) ## 适配HIP移植修改 ```shell 1. cmake相关 # 22.10 修改CMakeLists.txt,增加USE_HIP编译控制 新增cmake/modules/ROCM.cmake,参考cmake/modules/CUDA.cmake进行编译配置 增加CUDART_VERSION相关宏参数 # 23.04 添加"__HIP_PLATFORM_AMD__"宏参数,避免CPU代码编译问题 2. 源码修改 # 22.10 添加宏判断,设备上不支持iostream src/array/selector.h:34 hip结构体hipPointerAttribute_t适配 src/runtime/cuda/cuda_device_api.cc:251 添加显式基类限定词 src/runtime/cuda/cuda_hashtable.cu:60 src/runtime/cuda/cuda_hashtable.cu:104 src/runtime/cuda/cuda_hashtable.cu:110 添加对CUDART_VERSION相关的条件判断flag src/array/cuda/spmm_hetero.cu:59 src/array/cuda/spmm_hetero.cu:133 注释CUB_VERSION相关的static_assert检查 src/array/cuda/rowwise_sampling_prob.cu:20 注释CUDART_VERSION相关的static_assert检查 src/array/cuda/atomic.cuh:83 增加__HIPCC__宏定义的检查 include/dgl/array_iterator.h:9 # 23.04 修改__shfl_down_sync支持 src\array\cuda\sddmm.cuh:179 修改__syncwarp支持 src\array\cuda\gather_mm.cu:103 src\array\cuda\gather_mm.cu:164 ``` 3. 单元测试及python相关 修改`np.int`、`np.float`、`np.asscalar`为`int`、`float`、`np.ndarray.item`,并将`setup.py`中`numpy`依赖版本提高至`1.20.0`,统一dtype相关类型的代码,以避免单元测试和使用中问题