Top Related Projects
AMD ROCm™ Software - GitHub Home
Intel® Graphics Compute Runtime for oneAPI Level Zero and OpenCL™ Driver
Tensors and Dynamic neural networks in Python with strong GPU acceleration
An Open Source Machine Learning Framework for Everyone
Quick Overview
The ROCm (Radeon Open Compute) project is an open-source software platform for GPU-accelerated computing on AMD hardware. It provides a comprehensive suite of tools, libraries, and runtime environments for developers to leverage the power of AMD's Radeon GPUs in their applications.
Pros
- High-Performance Computing: ROCm is designed to deliver high-performance computing capabilities, making it suitable for a wide range of GPU-accelerated workloads, including machine learning, scientific computing, and data analytics.
- AMD Hardware Support: ROCm is optimized for AMD's Radeon GPUs, providing seamless integration and support for the latest hardware advancements.
- Open-Source: The ROCm project is open-source, allowing developers to contribute, collaborate, and customize the platform to suit their specific needs.
- Ecosystem Integration: ROCm integrates with popular open-source frameworks and libraries, such as TensorFlow, PyTorch, and OpenCL, enabling developers to leverage existing tools and workflows.
Cons
- Limited Platform Support: ROCm is primarily focused on AMD hardware, which may limit its adoption in environments where other GPU vendors (e.g., NVIDIA) are more prevalent.
- Steep Learning Curve: Transitioning from other GPU computing platforms to ROCm may require a significant learning curve, as developers need to familiarize themselves with the ROCm-specific tools and workflows.
- Compatibility Challenges: Maintaining compatibility with the latest hardware and software versions can be a challenge, as the ROCm ecosystem evolves rapidly.
- Documentation and Community: While the ROCm project has a growing community, the documentation and community support may not be as extensive as some other GPU computing platforms.
Code Examples
Since ROCm is a software platform and not a specific code library, the following examples demonstrate how to use ROCm for GPU-accelerated computing:
# Example 1: Using ROCm with TensorFlow
import tensorflow as tf
with tf.device('/device:GPU:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3])
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2])
c = tf.matmul(a, b)
print(c)
This example shows how to use ROCm with TensorFlow to perform a matrix multiplication on the GPU.
// Example 2: Using ROCm with OpenCL
#include <CL/cl.h>
int main() {
cl_platform_id platform;
cl_device_id device;
cl_context context;
cl_command_queue queue;
// Set up OpenCL environment using ROCm
// ...
// Enqueue kernel and execute
// ...
return 0;
}
This example demonstrates the integration of ROCm with OpenCL, allowing developers to leverage the GPU for general-purpose computing.
# Example 3: Using ROCm with PyTorch
import torch
import torch.nn as nn
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = nn.Linear(in_features=64, out_features=10).to(device)
input_tensor = torch.randn(1, 64).to(device)
output = model(input_tensor)
print(output)
This example shows how to use ROCm with PyTorch to run a simple neural network on the GPU.
Getting Started
To get started with ROCm, follow these steps:
-
Install ROCm: Visit the ROCm GitHub repository and follow the installation instructions for your operating system.
-
Set up the Development Environment: Ensure that your system is configured with the necessary dependencies and tools, such as compilers, libraries, and development tools.
-
Explore the ROCm Ecosystem: Familiarize yourself with the various components of the ROCm platform, including the ROCm runtime, ROCm compiler
Competitor Comparisons
AMD ROCm™ Software - GitHub Home
Pros of ROCm
- More comprehensive documentation and guides
- Broader community support and contributions
- Regular updates and maintenance
Cons of ROCm
- Larger repository size, potentially slower cloning
- More complex structure, steeper learning curve for newcomers
- May include unnecessary components for some users
Code Comparison
ROCm:
#include <hip/hip_runtime.h>
__global__ void vectorAdd(const float *A, const float *B, float *C, int numElements)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < numElements)
{
C[i] = A[i] + B[i];
}
}
ROCm>:
// No direct code comparison available as ROCm> is not a separate repository
// but rather a naming convention or typo in the original query.
Note: The comparison between ROCm/ROCm and ROCm/ROCm> appears to be based on a misunderstanding or typo. ROCm> is not a separate repository. The ROCm (Radeon Open Compute) project is maintained in the ROCm/ROCm repository on GitHub. As such, a direct comparison between these two is not possible. The information provided for ROCm is based on the actual repository, while no specific information can be given for ROCm> as it doesn't exist as a separate entity.
Intel® Graphics Compute Runtime for oneAPI Level Zero and OpenCL™ Driver
Pros of compute-runtime
- Broader hardware support for Intel GPUs and integrated graphics
- More extensive documentation and integration guides
- Active community with frequent updates and bug fixes
Cons of compute-runtime
- Limited to Intel hardware, less versatile than ROCm
- Smaller ecosystem of tools and libraries compared to ROCm
- Less focus on high-performance computing (HPC) workloads
Code Comparison
ROCm example (HIP):
#include <hip/hip_runtime.h>
__global__ void vectorAdd(float *a, float *b, float *c, int n) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < n) c[i] = a[i] + b[i];
}
compute-runtime example (OpenCL):
#include <CL/cl.h>
const char* kernelSource = "__kernel void vectorAdd(__global float *a, __global float *b, __global float *c, int n) {"
" int i = get_global_id(0);"
" if (i < n) c[i] = a[i] + b[i];"
"}";
Both repositories provide GPU acceleration capabilities, but ROCm focuses on AMD hardware and HPC workloads, while compute-runtime targets Intel GPUs and integrated graphics. ROCm uses HIP (a CUDA-like API) for programming, whereas compute-runtime primarily uses OpenCL. The code examples demonstrate the syntax differences between the two approaches.
Tensors and Dynamic neural networks in Python with strong GPU acceleration
Pros of PyTorch
- Widely adopted in the machine learning community with extensive documentation and tutorials
- Supports dynamic computational graphs, allowing for more flexible model architectures
- Offers a Pythonic interface, making it easier for developers to learn and use
Cons of PyTorch
- Generally slower performance on AMD GPUs compared to NVIDIA GPUs
- Limited support for AMD hardware optimization out-of-the-box
Code Comparison
PyTorch example:
import torch
x = torch.tensor([1, 2, 3])
y = torch.tensor([4, 5, 6])
z = x + y
print(z)
ROCm example (using HIP):
#include <hip/hip_runtime.h>
__global__ void vectorAdd(float *a, float *b, float *c, int n) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < n) c[i] = a[i] + b[i];
}
ROCm provides lower-level GPU programming capabilities, while PyTorch offers a high-level machine learning framework. ROCm is specifically designed for AMD GPUs, potentially offering better performance on AMD hardware. However, PyTorch has broader adoption and a more extensive ecosystem of tools and libraries for machine learning tasks.
An Open Source Machine Learning Framework for Everyone
Pros of TensorFlow
- Larger community and ecosystem, with more resources and third-party libraries
- Better documentation and tutorials for beginners
- Supports a wider range of hardware platforms, including CPUs and GPUs
Cons of TensorFlow
- Can be more complex and harder to learn for newcomers
- Slower development cycle compared to some other frameworks
- Larger memory footprint and potentially slower execution in some cases
Code Comparison
TensorFlow:
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])
ROCm:
#include <hip/hip_runtime.h>
__global__ void vectorAdd(float *a, float *b, float *c, int n) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < n) c[i] = a[i] + b[i];
}
Note that ROCm is a hardware acceleration platform, while TensorFlow is a machine learning framework. ROCm can be used to accelerate TensorFlow on AMD GPUs, but they serve different purposes. The code examples reflect their different use cases: TensorFlow for building neural networks, and ROCm for low-level GPU programming.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
AMD ROCm Software
ROCm is an open-source stack, composed primarily of open-source software, designed for graphics processing unit (GPU) computation. ROCm consists of a collection of drivers, development tools, and APIs that enable GPU programming from low-level kernel to end-user applications.
With ROCm, you can customize your GPU software to meet your specific needs. You can develop, collaborate, test, and deploy your applications in a free, open source, integrated, and secure software ecosystem. ROCm is particularly well-suited to GPU-accelerated high-performance computing (HPC), artificial intelligence (AI), scientific computing, and computer aided design (CAD).
ROCm is powered by AMDâs Heterogeneous-computing Interface for Portability (HIP), an open-source software C++ GPU programming environment and its corresponding runtime. HIP allows ROCm developers to create portable applications on different platforms by deploying code on a range of platforms, from dedicated gaming GPUs to exascale HPC clusters.
ROCm supports programming models, such as OpenMP and OpenCL, and includes all necessary open source software compilers, debuggers, and libraries. ROCm is fully integrated into machine learning (ML) frameworks, such as PyTorch and TensorFlow.
Getting the ROCm Source Code
AMD ROCm is built from open source software. It is, therefore, possible to modify the various components of ROCm by downloading the source code and rebuilding the components. The source code for ROCm components can be cloned from each of the GitHub repositories using git. For easy access to download the correct versions of each of these tools, the ROCm repository contains a repo manifest file called default.xml. You can use this manifest file to download the source code for ROCm software.
Installing the repo tool
The repo tool from Google allows you to manage multiple git repositories simultaneously. Run the following commands to install the repo tool:
mkdir -p ~/bin/
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Note: The ~/bin/
folder is used as an example. You can specify a different folder to install the repo tool into if you desire.
Installing git-lfs
Some ROCm projects use the Git Large File Storage (LFS) format that may require you to install git-lfs. Refer to Git Large File Storage for more information. For example, to install git-lfs for Ubuntu, use the following command:
sudo apt-get install git-lfs
Downloading the ROCm source code
The following example shows how to use the repo tool to download the ROCm source code. If you choose a directory other than ~/bin/ to install the repo tool, you must use that chosen directory in the code as shown below:
mkdir -p ~/ROCm/
cd ~/ROCm/
~/bin/repo init -u http://github.com/ROCm/ROCm.git -b roc-6.0.x
~/bin/repo sync
Note: Using this sample code will cause the repo tool to download the open source code associated with the specified ROCm release. Ensure that you have ssh-keys configured on your machine for your GitHub ID prior to the download as explained at Connecting to GitHub with SSH.
Building the ROCm source code
Each ROCm component repository contains directions for building that component, such as the rocSPARSE documentation Installation and Building for Linux. Refer to the specific component documentation for instructions on building the repository.
Each release of the ROCm software supports specific hardware and software configurations. Refer to System requirements (Linux) for the current supported hardware and OS.
Build ROCm from source
The Build will use as many processors as it can find to build in parallel. Some of the compiles can consume as much as 10GB of RAM, so make sure you have plenty of Swap Space !
By default the ROCm build will compile for all supported GPU architectures and will take approximately 500 CPU hours. The Build time will reduce significantly if we limit the GPU Architecture/s against which we need to build by using the environment variable GPU_ARCHS as mentioned below.
# --------------------------------------
# Step1: clone source code
# --------------------------------------
mkdir -p ~/WORKSPACE/ # Or any folder name other than WORKSPACE
cd ~/WORKSPACE/
export ROCM_VERSION=6.2.0
~/bin/repo init -u http://github.com/ROCm/ROCm.git -b roc-6.2.x -m tools/rocm-build/rocm-${ROCM_VERSION}.xml
~/bin/repo sync
# --------------------------------------
# Step 2: Prepare build environment
# --------------------------------------
# Option 1: Start a docker container
# Pulling required base docker images:
# Ubuntu20.04 built from ROCm/tools/rocm-build/docker/ubuntu20/Dockerfile
docker pull rocm/rocm-build-ubuntu-20.04:6.2
# Ubuntu22.04 built from ROCm/tools/rocm-build/docker/ubuntu22/Dockerfile
docker pull rocm/rocm-build-ubuntu-22.04:6.2
# Ubuntu24.04 built from ROCm/tools/rocm-build/docker/ubuntu24/Dockerfile
docker pull rocm/rocm-build-ubuntu-24.04:6.2
# Start docker container and mount the source code folder:
docker run -ti \
-e ROCM_VERSION=${ROCM_VERSION} \
-e CCACHE_DIR=$HOME/.ccache \
-e CCACHE_ENABLED=true \
-e DOCK_WORK_FOLD=/src \
-w /src \
-v $PWD:/src \
-v /etc/passwd:/etc/passwd \
-v /etc/shadow:/etc/shadow \
-v ${HOME}/.ccache:${HOME}/.ccache \
-u $(id -u):$(id -g) \
<replace_with_required_ubuntu_base_docker_image> bash
# Option 2: Install required packages into the host machine
# For ubuntu20.04 system
cd ROCm/tools/rocm-build/docker/ubuntu20
cp * /tmp && cd /tmp
bash install-prerequisites.sh
# For ubuntu22.04 system
cd ROCm/tools/rocm-build/docker/ubuntu22
cp * /tmp && cd /tmp
bash install-prerequisities.sh
# For ubuntu24.04 system
cd ROCm/tools/rocm-build/docker/ubuntu24
cp * /tmp && cd /tmp
bash install-prerequisites.sh
# --------------------------------------
# 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 packages in ubuntu24.04:
out/ubuntu-24.04/24.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/
# Find built logs in ubuntu24.04:
out/ubuntu-24.04/24.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
Note: Overview for ROCm.mk
ROCm documentation
This repository contains the manifest file for ROCm releases, changelogs, and release information.
The default.xml
file contains information for all repositories and the associated commit used to build
the current ROCm release; default.xml
uses the Manifest Format repository.
Source code for our documentation is located in the /docs
folder of most ROCm repositories. The
develop
branch of our repositories contains content for the next ROCm release.
The ROCm documentation homepage is rocm.docs.amd.com.
Building the documentation
For a quick-start build, use the following code. For more options and detail, refer to Building documentation.
cd docs
pip3 install -r sphinx/requirements.txt
python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html
Alternatively, CMake build is supported.
cmake -B build
cmake --build build --target=doc
Older ROCm releases
For release information for older ROCm releases, refer to the CHANGELOG.
Top Related Projects
AMD ROCm™ Software - GitHub Home
Intel® Graphics Compute Runtime for oneAPI Level Zero and OpenCL™ Driver
Tensors and Dynamic neural networks in Python with strong GPU acceleration
An Open Source Machine Learning Framework for Everyone
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot