0, 前言
如果初步接触 AMD这套,可以先在ubuntu上使用apt工具安装,并针对特定感兴趣的模块从源码编译安装替换,并开展研究。对整体感兴趣时可以考虑从源码编译安装整个ROCm生态。
1, 预制二进制通过apt 安装
待补。。。
2, 从源码安装
sudo apt-get install git-lfs
rocm也是使用 repo工具管理整个项目代码
mkdir -p ~/bin/
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
2.1 Step1: clone source code
mkdir -p ~/WORKSPACE/ && \
cd ~/WORKSPACE/ && \
export ROCM_VERSION=6.1.0 && \
~/bin/repo init -u http://github.com/ROCm/ROCm.git -b roc-6.1.x -m tools/rocm-build/rocm-${ROCM_VERSION}.xml && \
~/bin/repo sync
2.2 Step 2: Prepare build environment
2.2.1Prepare prepare build environment
fatal error: curl/curl.h: No such file or directory
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev
sudo yum install libcurl-devl
fatal error: expat.h: No such file or directory
sudo apt-get update
sudo apt-get install libexpat1-dev
sudo yum install expat-devl
msgfmt: not found
sudo apt-get update
sudo apt-get install gettext
sudo yum install gettext
pip3: command not found
sudo apt-get update
sudo apt install python3-pip
2.2.2 Prepare build environment
# For ubuntu20.04 system
cd ROCm/tools/rocm-build/docker/ubuntu20
bash install-prerequisites.sh
# For ubuntu22.04 system
cd ROCm/tools/rocm-build/docker/ubuntu22
bash install-prerequisities.sh
这个 install-prerequisities.sh 会下载 (wget、 git clone 等等)很多源代码并编译,如果网速还行的话,运行时间需要按照一个小时左右来预备,跟cpu和内存也有关系 。
截一个几十分钟后的图:
2.3 Step 3: Run build command line
# Select GPU targets before building:
# When GPU_ARCHS is not set, default GPU targets supported by ROCm6.1 will be used.
# To build against a subset of GFX architectures you can use the below env variable.
# Support MI300 (gfx940, gfx941, gfx942).
export GPU_ARCHS="gfx942" # Example
export GPU_ARCHS="gfx940;gfx941;gfx942" # Example
# Pick and run build commands in the docker container:
# Build rocm-dev packages
make -f ROCm/tools/rocm-build/ROCm.mk -j ${NPROC:-$(nproc)} rocm-dev
# Build all ROCm packages
make -f ROCm/tools/rocm-build/ROCm.mk -j ${NPROC:-$(nproc)} all
# list all ROCm components to find required components
make -f ROCm/tools/rocm-build/ROCm.mk list_components
# Build a single ROCm packages
make -f ROCm/tools/rocm-build/ROCm.mk T_rocblas
# Find built packages in ubuntu20.04:
out/ubuntu-20.04/20.04/deb/
# Find built packages in ubuntu22.04:
out/ubuntu-22.04/22.04/deb/
# Find built logs in ubuntu20.04:
out/ubuntu-20.04/20.04/logs/
# Find built logs in ubuntu22.04:
out/ubuntu-22.04/22.04/logs/
# All logs pertaining to failed components, end with .errrors extension.
out/ubuntu-22.04/22.04/logs/rocblas.errors # Example
# All logs pertaining to building components, end with .inprogress extension.
out/ubuntu-22.04/22.04/logs/rocblas.inprogress # Example
# All logs pertaining to passed components, use the component names.
out/ubuntu-22.04/22.04/logs/rocblas # Example
效果图示:
待补。。。