Installing and building rocSPARSE for Linux#
This topic describes how to install or build rocSPARSE on Linux by using prebuilt packages or building from source.
Prerequisites#
rocSPARSE requires a ROCm enabled platform. For more information, including a list of supported GPUs and Linux distributions, see the ROCm on Linux install guide.
Installing pre-built packages#
Use the following commands to install rocSPARSE on Ubuntu or Debian:
sudo apt-get update
sudo apt-get install rocsparse
Use the following commands to install rocSPARSE on RHEL-based platforms:
sudo yum update
sudo yum install rocsparse
Use the following commands to install rocSPARSE on SLES:
sudo dnf upgrade
sudo dnf install rocsparse
After rocSPARSE is installed, it can be used just like any other library with a C API. To call rocSPARSE, the header file must be included in the user code. This means the rocSPARSE shared library becomes a link-time and run-time dependency for the user application.
Building rocSPARSE from source#
It isn’t necessary to build rocSPARSE from source because it’s ready to use after installing the prebuilt packages, as described above. To build rocSPARSE from source, follow the instructions in this section.
Requirements#
To compile and run rocSPARSE, the AMD ROCm Platform is required. Building rocSPARSE from source also requires the following components and dependencies:
CMake (Version 3.5 or later)
rocBLAS (Optional: for the library)
GoogleTest (Optional: only required to build the clients)
When building rocSPARSE from source, select supported versions of the math library dependencies (rocPRIM and optionally rocBLAS). Given a version of rocSPARSE, you must use a version of rocPRIM (and optionally rocBLAS) that is the same or later. For example, it’s possible to build rocSPARSE 3.2.0 with any future rocPRIM 3.Y.Z version (with the same major version and where 3.Y.Z is 3.2.0 or later), but compiling rocSPARSE with an older version of rocPRIM, such as 3.1.0, is not supported.
Downloading rocSPARSE#
The rocSPARSE source code is available from the rocSPARSE GitHub. Download the develop branch using these commands:
git clone -b develop https://github.com/ROCm/rocSPARSE.git
cd rocSPARSE
Building rocSPARSE using the install script#
It’s recommended to use the install.sh
script to install rocSPARSE.
Here are the steps required to build different packages of the library, including the dependencies and clients.
Using install.sh to build rocSPARSE with dependencies#
The following table lists the common ways to use install.sh
to build the rocSPARSE dependencies and library.
Command |
Description |
---|---|
|
Print the help information. |
|
Build the dependencies and library in your local directory. The |
|
Build the library in your local directory. The script assumes the dependencies are available. |
|
Build the library, then build and install the rocSPARSE package in |
|
Build the library specifically for the gfx908 architecture, then build and install the rocSPARSE package in |
Using install.sh to build rocSPARSE with dependencies and clients#
The clients contain example code, unit tests, and benchmarks. Common use cases of install.sh
to build
the library, dependencies, and clients are listed in the table below.
Command |
Description |
---|---|
|
Print the help information. |
|
Build the dependencies, library, and client in your local directory. The |
|
Build the library and client in your local directory. The script assumes the dependencies are available. |
|
Build the library, dependencies, and client, then build and install the rocSPARSE package in |
|
Build the library and client, then build and install the rocSPARSE package in |
|
Build the library specifically for the gfx908 architecture, build the dependencies and client, then build and install the rocSPARSE package in |
|
Build the library specifically for the gfx908 architecture, build the client, then build and install the rocSPARSE package in |
Building rocSPARSE using individual make commands#
The rocSPARSE library contains both host and device code, therefore, the HIP compiler must be specified during the CMake configuration process.
You can build rocSPARSE using the following commands:
Note
CMake 3.5 or later is required to build rocSPARSE.
# Create and change to build directory
mkdir -p build/release ; cd build/release
# Default install path is /opt/rocm, use -DCMAKE_INSTALL_PREFIX=<path> to adjust it
CXX=/opt/rocm/bin/amdclang++ cmake ../..
# Compile rocSPARSE library
make -j$(nproc)
# Install rocSPARSE to /opt/rocm
make install
You can build rocSPARSE with the dependencies and clients using the following commands:
Note
GoogleTest is required to build rocSPARSE clients.
# Install GoogleTest
mkdir -p build/release/deps ; cd build/release/deps
cmake ../../../deps
make -j$(nproc) install
# Change to build directory
cd ..
# Default install path is /opt/rocm, use -DCMAKE_INSTALL_PREFIX=<path> to adjust it
CXX=/opt/rocm/bin/amdclang++ cmake ../.. -DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DBUILD_CLIENTS_SAMPLES=ON
# Compile rocSPARSE library
make -j$(nproc)
# Install rocSPARSE to /opt/rocm
make install
Resolving common build problems#
If you encounter the error message “Could not find a package configuration file provided by “ROCm” with any of the following names: ROCMConfig.cmake, rocm-config.cmake” during the build, install the ROCm CMake modules.
Testing rocSPARSE#
You can test the rocSPARSE installation by running one of the rocSPARSE examples after successfully compiling the library with the clients.
# Navigate to clients binary directory
cd rocSPARSE/build/release/clients/staging
# Execute rocSPARSE example
./example_csrmv 1000