Skip to content

Commit b3fe46d

Browse files
committed
Save current progress
Signed-off-by: Gavin Zhao <[email protected]>
1 parent 5e6de23 commit b3fe46d

File tree

1 file changed

+189
-0
lines changed
  • docs/user/software/development

1 file changed

+189
-0
lines changed
+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
---
2+
title: ROCm/HIP
3+
summary: A quick guide to getting set up for ROCm/HIP development on Solus
4+
---
5+
6+
# ROCm/HIP
7+
8+
ROCm is AMD's open-source software stack for GPU computation.
9+
10+
Note that ROCm is not required in order for, say, your display or browser, to
11+
use GPU-acclerated rendering. These are more on the driver side of things and
12+
are
13+
handled by the kernel and/or Mesa. ROCm is mainly focused on GPU-accelerated
14+
computing, such as GPU rendering in Blender or GPU-accelerated machine learning
15+
in PyTorch.
16+
17+
## Install ROCm/HIP
18+
19+
```bash
20+
sudo eopkg it rocm-hip rocm-opencl
21+
```
22+
23+
If you are also developing with ROCm/HIP, install the
24+
development files and the `hipcc` compiler driver as well:
25+
```bash
26+
sudo eopkg it rocm-hip-devel
27+
```
28+
29+
## Necessary Environment Variables
30+
31+
It is recommended and safe to put these environment variables in your
32+
`~/.bashrc`:
33+
```bash
34+
export ROCM_PATH=/usr
35+
export HIP_PATH=/usr
36+
```
37+
38+
If you're developing with ROCm/HIP, the following environment variables will
39+
save you a lot of hassle:
40+
```bash
41+
export HIP_DEVICE_LIB_PATH=/usr/lib64/amdgcn/bitcode
42+
export DEVICE_LIB_PATH=$HIP_DEVICE_LIB_PATH
43+
export HIP_PLATFORM=amd
44+
export HIP_RUNTIME=amd
45+
export HIP_ROCCLR_HOME=$ROCM_PATH
46+
```
47+
48+
## Supported Hardware and GPU Architectures
49+
50+
<!--
51+
ROCm is designed such that in order to for the compiled binaries to run on a
52+
certain GPU model, during compiling one must compile with that GPU as the
53+
compilation target.
54+
!-->
55+
56+
ROCm is designed such that in order for a library to support N different GPU
57+
architectures, that library must be compiled N times, once for each
58+
architecture, causing the build time of a package to grow linearly. For example,
59+
if we want PyTorch to support running on 5 different GPU architectures, we
60+
essentially need to compile PyTorch 5 times. It should be obvious this quickly
61+
becomes a maintenance burden as the compile time grows linearly with respect to
62+
the number of GPUs models we want to support.
63+
64+
Therefore, we have carefuly picked
65+
the following baseline
66+
architectures such that we support as many reasonably recent
67+
hardware as possible while not causing compilation times to skyrocket. Any GPU
68+
architecture in the list below should work out-of-the-box.
69+
70+
- `gfx803`
71+
- `gfx900`
72+
- `gfx906`
73+
- `gfx908`
74+
- `gfx90a`
75+
- `gfx1010`; for `gfx101*` GPUs such as `gfx1011` and `gfx1012`, see [Emulating
76+
as a Supported Architecture](#emulating-as-a-supported-architecture) section.
77+
- `gfx1030`; for `gfx103*` GPUs such as `gfx1031` and `gfx1032`, see [Emulating
78+
as a Supported Architecture](#emulating-as-a-supported-architecture) section.
79+
- `gfx1010`
80+
- `gfx1011`
81+
- `gfx1012`
82+
83+
:::tip
84+
85+
Run `rocminfo` provided by the `rocminfo` package to
86+
see what architecture your GPU(s) have.
87+
88+
:::
89+
90+
:::note
91+
92+
This list is only the minimum supported architectures. Some packages like
93+
[Blender](#blender) are built with support for even more architectures.
94+
95+
:::
96+
97+
If your GPU model is not on the list, please open an issue in
98+
our [Issue Tracker] with your GPU model and the year that this model is
99+
released.
100+
101+
### Emulating as a Supported Architecture
102+
103+
Several GPU archiectures, such as those in the Navi 1 family, have
104+
almost identical (if not exactly identical) ISA that allows a program compiled for
105+
one architecture to run seamlessly on other.
106+
For example, any program compiled for the `gfx1030` architecture can also run on
107+
the `gfx1031` and `gfx1032` architectures. A list of such architectures is
108+
listed in the previous section.
109+
110+
To emulate your GPU as a supported architecture, the environment variable
111+
`HSA_OVERRIDE_GFX_VERSION` must be specified. Examples:
112+
113+
Emulating as `gfx1030`:
114+
```bash
115+
export HSA_OVERRIDE_GFX_VERSION=10.3.0
116+
```
117+
118+
Emulating as `gfx1010`:
119+
```bash
120+
export HSA_OVERRIDE_GFX_VERSION=10.1.0
121+
```
122+
123+
Emulating as `gfx900`:
124+
```bash
125+
export HSA_OVERRIDE_GFX_VERSION=9.0.0
126+
```
127+
128+
## Specifying which GPU to use
129+
130+
Sometimes, it may be hard or impossible to tell your program to use the GPU
131+
that you want. This not only happnes on a system with multiple GPUs; this can
132+
also happen when your CPU is also made by AMD and has an
133+
integrated GPU. You can check whether your CPU has usable integrated graphics as
134+
well by running `linux-driver-management status`. If your CPU has
135+
integrated graphics and you have turned on switchable/hybrid graphics in your
136+
BIOS, you may see something like the following:
137+
```
138+
Hybrid Graphics
139+
140+
╒ Primary GPU (iGPU)
141+
╞ Device Name : Cezanne [Radeon Vega Series / Radeon Vega Mobile Series]
142+
╞ Manufacturer : Advanced Micro Devices, Inc. [AMD/ATI]
143+
╞ Product ID : 0x1669
144+
╞ Vendor ID : 0x1002
145+
╞ X.Org PCI ID : PCI:7:0:0
146+
╘ Boot VGA : yes
147+
148+
╒ Secondary GPU (dGPU)
149+
╞ Device Name : Navi 23 [Radeon RX 6600/6600 XT/6600M]
150+
╞ Manufacturer : Advanced Micro Devices, Inc. [AMD/ATI]
151+
╞ Product ID : 0x73ab
152+
╞ Vendor ID : 0x1002
153+
╞ X.Org PCI ID : PCI:2:0:0
154+
╘ Boot VGA : no
155+
```
156+
157+
ROCm/HIP offers the environment variable `HIP_VISIBLE_DEVICES` to control which
158+
GPUs are visible to a process from the ROCm/HIP API. Only devices whose index
159+
is present in the sequence are visible to HIP. For example, `export
160+
HIP_VISIBLE_DEVICES=0` makes only the GPU with device index 0 visible, and
161+
`export HIP_VISIBLE_DEVICES=0,2` makes only the GPUs with device indices 0 and 2
162+
visible.
163+
164+
:::caution
165+
166+
The device index is **NOT** its agent number in the output of `rocminfo`! You
167+
can find your device's corresponding index through the output of `rocm-smi`,
168+
provided by the `rocm-smi` package.
169+
170+
:::
171+
172+
:::note
173+
174+
As suggested by its name, `HIP_VISIBLE_DEVICES` only hides the GPU from the
175+
ROCm/HIP side. A program can still access GPUs hidden by `HIP_VISIBLE_DEVICES`
176+
by calling other graphics APIs such as OpenGL.
177+
178+
:::
179+
180+
## Software-Specific Instructions
181+
182+
### Blender
183+
184+
### PyTorch
185+
186+
187+
## Reporting an Issue
188+
189+

0 commit comments

Comments
 (0)