您的位置:首页 > 汽车 > 时评 > 源码安装 AMD GPGPU 生态 ROCm 备忘

源码安装 AMD GPGPU 生态 ROCm 备忘

2024/11/17 18:27:16 来源:https://blog.csdn.net/eloudy/article/details/140573549  浏览:    关键词:源码安装 AMD GPGPU 生态 ROCm 备忘

 

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

no such file or directory: python
 

cd /usr/bin
sudo ln -s python3 python

/opt/Python-3.8.13 exist

无论什么因素导致中断,在重新执行 sudo bash install--prerequisities.sh
之前,需要先删除如下文件,他们会被重新构建:

 

sudo rm /usr/grpc/ -rf && \
sudo rm /tmp/grpc/ -rf && \
sudo rm /opt/Python-3.8.13/ -rf && \
sudo rm /usr/blis/amd-blis-mt -rf && \
sudo rm /usr/blis/ -rf

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和内存也有关系 。

重要的事情说两遍:

过程中会因为各种因素而中断, 无论什么因素导致中断,在重新执行 sudo bash install--prerequisities.sh
之前,需要先删除如下文件,他们会被重新构建,并检查这些文件夹,故不能事先存在这些文件夹:
 

sudo rm /usr/grpc/ -rf && \
sudo rm /tmp/grpc/ -rf && \
sudo rm /opt/Python-3.8.13/ -rf && \
sudo rm /usr/blis/amd-blis-mt -rf && \
sudo rm /usr/blis/ -rf

sudo bash install--prerequisities.sh 执行后,截一个几十分钟后的图:

install_prerequisities.sh执行完毕后是这个样子:


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

效果图示:

待补。。。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com