1 What is ROCm
AMD ROCm is the abbreviation of Radeon Open Compute. It is an open source software development platform provided by AMD for HPC and ultra-large-scale GPU computing. AMD ROCm brings the UNIX concept of minimalism and modular software development to GPU computing.
ROCm includes a series of development tools, software frameworks, libraries, compilation tools, programming models, etc., including:
frameworks :Tensorflow / PyTorch / Kokkos
libraries :MIOpen / Blas / RCCL / ROC*
programming model:HIP / OpenCL
Intermediate runtimes and compilers:LLVM based clang (HIP Clang)
Programmer and system tools: debug / profile
Kernel Driver:
etc.
All components of ROCm are as follows:
2 How to install ROCm
AMD officially provides a complete installation package, the installation is relatively simple, or you can use a virtual machine/docker. This article describes how to install some components of ROCm through source code.
The ROCm code repository is stored at https://github.com/RadeonOpenCompute and is managed through the android code management tool repo.
2.1 Download source code
# 使用roc-4.3.x分支
repo init -u https://github.com/RadeonOpenCompute/ROCm.git -b roc-4.3.x
repo sync
The sync warehouse takes a long time. After completion, all the codes of all components of ROCm will be downloaded:
qihangkong@ubuntu:~/git/rocm$ ls
AMDMIGraphX MIOpen ROCK-Kernel-Driver ROCdbgapi ROCm-OpenCL-Runtime
clang-ocl hipFFT openmp-extras rocBLAS rocSOLVER
rocm_bandwidth_test rocr_debug_agent
HIP MIOpenGEMM ROCR-Runtime ROCgdb ROCmValidationSuite
half hipSPARSE rccl rocFFT rocSPARSE
rocm_smi_lib roctracer HIP-Examples MIVisionX ROCT-Thunk-Interface
ROCm-CompilerSupport Tensile hipBLAS hipfort
rdc rocPRIM rocThrust rocminfo HIPIFY RCP
ROCclr ROCm-Device-Libs atmi hipCUB
llvm-project rocALUTION rocRAND rocm-cmake rocprofiler
2.2 Compile the source code
There is no unified installation script in the ROCm source code directory, so it is necessary to compile components one by one, and there is interdependence between the components for compilation and installation. You can follow the installation sequence as follows:
llvm-project
mkdir -p build; cd build
cmake ../llvm -DCMAKE_INSTALL_PREFIX=${TO_INSTALL_PATH} -DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" -DLLVM_ENABLE_PROJECTS="llvm;clang;lld;compiler-rt"
make -j ${JOB_NUM}; make install
ROCm-Device-Libs
mkdir -p build; cd build
cmake ../ -DLLVM_DIR=${LLVM_BUILD_PATH} -DLLVM_ENABLE_WERROR=1 -DLLVM_ENABLE_ASSERTIONS=1 -DCMAKE_INSTALL_PREFIX=${TO_INSTALL_PATH}
make -j ${JOB_NUM}; make install
ROCm-CompilerSupport
mkdir -p build; cd build
cmake ../ -DCMAKE_PREFIX_PATH="${LLVM_BUILD_PATH};${DEVICELIBS_BUILD_PATH}" -DCMAKE_INSTALL_PREFIX=${TO_INSTALL_PATH}
make -j ${JOB_NUM}; make install
ROCT-Thunk-Interface
mkdir -p build; cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=${TO_INSTALL_PATH}
make -j ${JOB_NUM}; make install
ROCR-Runtime
mkdir -p build; cd build
cmake ../ -DCMAKE_PREFIX_PATH="${LLVM_BUILD_PATH}" -DCMAKE_INSTALL_PREFIX=${TO_INSTALL_PATH}
make -j ${JOB_NUM}; make install
ROCclr
mkdir -p build; cd build
cmake ../ -DOPENCL_DIR=${BUILD_TOP_PATH}/ROCm-OpenCL-Runtime -DCMAKE_INSTALL_PREFIX=${TO_INSTALL_PATH}
make -j ${JOB_NUM}; make install
OpenCL Runtime
mkdir -p build; cd build
cmake ../ -DUSE_COMGR_LIBRARY=ON -DCMAKE_PREFIX_PATH="${ROCCLR_BUILD_PATH};${TO_INSTALL_PATH}" -DCMAKE_INSTALL_PREFIX=${TO_INSTALL_PATH}
make -j ${JOB_NUM}; make install
HIP
mkdir -p build; cd build
cmake ../ -DCMAKE_PREFIX_PATH="${ROCCLR_BUILD_PATH};${TO_INSTALL_PATH}" -DCMAKE_INSTALL_PREFIX=${TO_INSTALL_PATH} -DHSA_PATH=${TO_INSTALL_PATH}
make -j ${JOB_NUM}; make install
3 Summary compilation script
The above compilation and installation process has been repeatedly compiled several times, and there is a problem with parameter setting, so write the above process as a script, directly copy the following script and run it to compile and install correctly:
Script address: https://gitee.com/qihangkong/syscfg/blob/master/scripts/build_rocm.sh
If there is no need to read the source code, it is recommended to install it in the form of an installation package . There are many problems in compiling and installing
TODO:
Compile and install the rest of the components