Files
rocm-systems/INSTALL.md
T

125 строки
4.7 KiB
Markdown
Исходник Обычный вид История

2016-07-25 14:53:15 +05:30
## Table of Contents
<!-- toc -->
- [Installing pre-built packages](#installing-pre-built-packages)
* [Prerequisites](#prerequisites)
2020-11-02 15:54:42 -05:00
* [AMD Platform](#amd-platform)
* [NVIDIA Platform](#nvidia-platform)
2016-05-02 10:19:46 -05:00
- [Building HIP from source](#building-hip-from-source)
2020-11-02 15:54:42 -05:00
* [Build ROCclr](#build-rocclr)
* [Build HIP](#build-hip)
* [Default paths and environment variables](#default-paths-and-environment-variables)
- [Verify your installation](#verify-your-installation)
2016-07-25 14:53:15 +05:30
<!-- tocstop -->
2016-05-02 10:19:46 -05:00
# Installing pre-built packages
HIP can be easily installed using pre-built binary packages using the package manager for your platform.
## Prerequisites
2020-11-02 15:54:42 -05:00
HIP code can be developed either on AMD ROCm platform using HIP-Clang compiler, or a CUDA platform with nvcc installed.
2016-05-02 10:19:46 -05:00
2020-11-02 15:54:42 -05:00
## AMD Platform
2016-05-02 10:19:46 -05:00
2019-01-04 11:04:47 +05:30
```
2020-11-02 15:54:42 -05:00
sudo apt install mesa-common-dev
sudo apt install clang
sudo apt install comgr
sudo apt-get -y install rocm-dkms
2019-01-04 11:04:47 +05:30
```
2020-11-02 15:54:42 -05:00
Public link for Rocm installation
https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html
2016-05-02 10:19:46 -05:00
2020-11-02 15:54:42 -05:00
HIP-Clang is the compiler for compiling HIP programs on AMD platform.
2020-01-06 02:02:47 -05:00
2020-11-02 15:54:42 -05:00
HIP-Clang can be built manually:
2020-01-06 02:02:47 -05:00
```
2021-04-01 18:40:43 -04:00
git clone -b rocm-4.3.x https://github.com/RadeonOpenCompute/llvm-project.git
2020-11-02 15:54:42 -05:00
cd llvm-project
2020-01-06 02:02:47 -05:00
mkdir -p build && cd build
2020-11-02 15:54:42 -05:00
cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" ../llvm
2020-01-06 02:02:47 -05:00
make -j
sudo make install
```
2018-05-31 23:55:42 -04:00
2020-11-02 15:54:42 -05:00
Rocm device library can be manually built as following,
2020-01-06 02:02:47 -05:00
```
export PATH=/opt/rocm/llvm/bin:$PATH
2021-04-01 18:40:43 -04:00
git clone -b rocm-4.3.x https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git
2020-01-06 02:02:47 -05:00
cd ROCm-Device-Libs
mkdir -p build && cd build
2020-11-02 15:54:42 -05:00
CC=clang CXX=clang++ cmake -DLLVM_DIR=/opt/rocm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_WERROR=1 -DLLVM_ENABLE_ASSERTIONS=1 -DCMAKE_INSTALL_PREFIX=/opt/rocm ..
2020-01-06 02:02:47 -05:00
make -j
sudo make install
```
2020-11-02 15:54:42 -05:00
## NVIDIA Platform
2018-05-31 23:55:42 -04:00
2020-11-02 15:54:42 -05:00
HIP-nvcc is the compiler for HIP program compilation on NVIDIA platform.
2016-05-02 10:19:46 -05:00
2019-01-04 11:04:47 +05:30
* Add the ROCm package server to your system as per the OS-specific guide available [here](https://rocm.github.io/ROCmInstall.html#installing-from-amd-rocm-repositories).
* Install the "hip-nvcc" package. This will install CUDA SDK and the HIP porting layer.
2016-05-02 10:19:46 -05:00
```
apt-get install hip-nvcc
2016-05-02 10:19:46 -05:00
```
* Default paths and environment variables:
2020-11-02 15:54:42 -05:00
* By default HIP looks for CUDA SDK in /usr/local/cuda (can be overriden by setting CUDA_PATH env variable).
2016-05-02 10:19:46 -05:00
* By default HIP is installed into /opt/rocm/hip (can be overridden by setting HIP_PATH environment variable).
* Optionally, consider adding /opt/rocm/bin to your path to make it easier to use the tools.
2020-11-02 15:54:42 -05:00
# Building HIP from source
2016-05-02 10:19:46 -05:00
2020-11-02 15:54:42 -05:00
## Build ROCclr
2016-05-02 10:19:46 -05:00
2020-11-02 15:54:42 -05:00
ROCclr is defined on AMD platform that HIP use Radeon Open Compute Common Language Runtime (ROCclr), which is a virtual device interface that HIP runtimes interact with different backends.
See https://github.com/ROCm-Developer-Tools/ROCclr
2016-05-02 10:19:46 -05:00
2020-11-02 15:54:42 -05:00
```
2021-04-01 18:40:43 -04:00
git clone -b rocm-4.3.x https://github.com/ROCm-Developer-Tools/ROCclr.git
2020-11-02 15:54:42 -05:00
export ROCclr_DIR="$(readlink -f ROCclr)"
2021-04-01 18:40:43 -04:00
git clone -b rocm-4.3.x https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git
2020-11-02 15:54:42 -05:00
export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)"
cd "$ROCclr_DIR"
mkdir -p build;cd build
cmake -DOPENCL_DIR="$OPENCL_DIR" -DCMAKE_INSTALL_PREFIX=/opt/rocm/rocclr ..
make -j
sudo make install
```
2019-03-30 08:24:49 -04:00
2020-11-02 15:54:42 -05:00
## Build HIP
2019-03-30 08:24:49 -04:00
2016-05-02 10:19:46 -05:00
```
2021-04-01 18:40:43 -04:00
git clone -b rocm-4.3.x https://github.com/ROCm-Developer-Tools/HIP.git
2020-11-02 15:54:42 -05:00
export HIP_DIR="$(readlink -f HIP)"
cd "$HIP_DIR"
mkdir -p build; cd build
2020-11-27 20:13:14 -05:00
cmake -DCMAKE_PREFIX_PATH="$ROCclr_DIR/build;/opt/rocm/" -DCMAKE_INSTALL_PREFIX=</where/to/install/hip> ..
2020-11-02 15:54:42 -05:00
make -j
sudo make install
2020-11-27 20:13:14 -05:00
Note: If you don't specify CMAKE_INSTALL_PREFIX, hip-rocclr runtime will be installed to "/opt/rocm/hip".
2016-05-02 10:19:46 -05:00
```
2020-11-02 15:54:42 -05:00
## Default paths and environment variables
2016-05-02 10:19:46 -05:00
2020-11-02 15:54:42 -05:00
* By default HIP looks for HSA in /opt/rocm/hsa (can be overridden by setting HSA_PATH environment variable).
* By default HIP is installed into /opt/rocm/hip (can be overridden by setting HIP_PATH environment variable).
* By default HIP looks for clang in /opt/rocm/llvm/bin (can be overridden by setting HIP_CLANG_PATH environment variable)
* By default HIP looks for device library in /opt/rocm/lib (can be overridden by setting DEVICE_LIB_PATH environment variable).
* Optionally, consider adding /opt/rocm/bin to your PATH to make it easier to use the tools.
* Optionally, set HIPCC_VERBOSE=7 to output the command line for compilation.
2016-05-02 10:19:46 -05:00
2020-11-02 15:54:42 -05:00
After installation, make sure HIP_PATH is pointed to /where/to/install/hip
# Verify your installation
Run hipconfig (instructions below assume default installation path) :
2016-05-02 10:19:46 -05:00
```shell
2020-11-02 15:54:42 -05:00
/opt/rocm/bin/hipconfig --full
2016-05-02 10:19:46 -05:00
```
2020-11-02 15:54:42 -05:00
2021-04-01 18:40:43 -04:00
Compile and run the [square sample](https://github.com/ROCm-Developer-Tools/HIP/tree/main/samples/0_Intro/square).
2016-05-02 10:19:46 -05:00