【Help for installing Gromacs in Ubuntu 20.04 with AMD RX570 GPU】

GROMACS version: 2021.3
GROMACS modification: No
OS: Ubuntu 20.04
CPU: core i5 6400

I am new to Gromacs and I would like to install it with GPU support of my AMD graphics card.
It is stated that the OpenCL can be used for this purpose. I followed the step in the documentation but I found no luck to get it right…

Here is my step to install Gromacs.
First I got the latest AMD driver for ubuntu.
I finished installed it with amdgpu-pro-install -y --opencl=rocr,legacy and check the OpenCL version with /opt/amdgpu-pro/bin/clinfo
I got the following output:

Number of platforms: 1
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 2.1 AMD-APP (3302.5)
Platform Name: AMD Accelerated Parallel Processing
Platform Vendor: Advanced Micro Devices, Inc.
Platform Extensions: cl_khr_icd cl_amd_event_callback cl_amd_offline_devices

Platform Name: AMD Accelerated Parallel Processing
Number of devices: 1
Vendor ID: 1002h
Board name: Radeon RX 570 Series
Device Topology: PCI[ B#1, D#0, F#0 ]
Max compute units: 32
Max work items dimensions: 3
Max work items[0]: 1024
Max work items[1]: 1024
Max work items[2]: 1024
Max work group size: 256
Preferred vector width char: 4
Preferred vector width short: 2
Preferred vector width int: 1
Preferred vector width long: 1
Preferred vector width float: 1
Preferred vector width double: 1
Native vector width char: 4
Native vector width short: 2
Native vector width int: 1
Native vector width long: 1
Native vector width float: 1
Native vector width double: 1
Max clock frequency: 1300Mhz
Address bits: 64
Max memory allocation: 3650722201
Image support: Yes
Max number of images read arguments: 128
Max number of images write arguments: 64
Max image 2D width: 16384
Max image 2D height: 16384
Max image 3D width: 2048
Max image 3D height: 2048
Max image 3D depth: 2048
Max samplers within kernel: 16
Max size of kernel argument: 1024
Alignment (bits) of base address: 2048
Minimum alignment (bytes) for any datatype: 128
Single precision floating point capability
Denorms: No
Quiet NaNs: Yes
Round to nearest even: Yes
Round to zero: Yes
Round to +ve and infinity: Yes
IEEE754-2008 fused multiply-add: Yes
Cache type: Read/Write
Cache line size: 64
Cache size: 16384
Global memory size: 4294967296
Constant buffer size: 3650722201
Max number of constant args: 8
Local memory type: Scratchpad
Local memory size: 65536
Max pipe arguments: 16
Max pipe active reservations: 16
Max pipe packet size: 3650722201
Max global variable size: 3285649920
Max global variable preferred total size: 4294967296
Max read/write image args: 64
Max on device events: 1024
Queue on device max size: 8388608
Max on device queues: 1
Queue on device preferred size: 262144
SVM capabilities:
Coarse grain buffer: Yes
Fine grain buffer: Yes
Fine grain system: No
Atomics: No
Preferred platform atomic alignment: 0
Preferred global atomic alignment: 0
Preferred local atomic alignment: 0
Kernel Preferred work group size multiple: 64
Error correction support: 0
Unified memory for Host and Device: 0
Profiling timer resolution: 1
Device endianess: Little
Available: Yes
Compiler available: Yes
Execution capabilities:
Execute OpenCL kernels: Yes
Execute native function: No
Queue on Host properties:
Out-of-Order: No
Profiling : Yes
Queue on Device properties:
Out-of-Order: Yes
Profiling : Yes
Platform ID: 0x7fdec073bf10
Name: Ellesmere
Vendor: Advanced Micro Devices, Inc.
Device OpenCL C version: OpenCL C 2.0
Driver version: 3302.5 (PAL,HSAIL)
Version: OpenCL 2.0 AMD-APP (3302.5)
Extensions: cl_khr_fp64 cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_gl_sharing cl_khr_gl_depth_images cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_media_ops2 cl_amd_popcnt cl_khr_image2d_from_buffer cl_khr_subgroups cl_khr_gl_event cl_khr_depth_images cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_amd_copy_buffer_p2p

I also update the cmake and all prerequisites.
Therefore, I go to extract the gromacs tar and cd to build.

It showed that the OpenCL is not found… So, I ran sudo apt install opencl-headers && sudo apt install ocl-icd-libopencl1
I ran the cmake again. But it still cannot find OpenCL…
So, I ran sudo apt install ocl-icd-opencl-dev.
The cmake this time found the OpenCL. However, it still cannot build the Gromacs. I got the following error:

– GPU support with OpenCL is deprecated. It is still fully supported (and recommended for AMD and Intel GPUs). It may be replaced by different approaches in future releases of GROMACS.
CMake Error at cmake/gmxManageOpenCL.cmake:53 (message):
OpenCL is not supported. OpenCL version 1.2 or newer is required.
Call Stack (most recent call first):
CMakeLists.txt:584 (include)

– Configuring incomplete, errors occurred!
See also “/home/ikki/Downloads/gromacs-2021.3/build/CMakeFiles/CMakeOutput.log”.
See also “/home/ikki/Downloads/gromacs-2021.3/build/CMakeFiles/CMakeError.log”.

I got stuck at this point…
What can I do to resolved this issue?
Thank you very much!

Edit (2021.10.23):

After I install the amd app sdk (found in this post AMD LINUX - Download AMD driver and SDK (github.com)) and run cmake … -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=OpenCL -DCMAKE_PREFIX_PATH=/opt/AMDAPPSDK-3.0
It is successfully make the build.
Unfortunately, when I tried to run make, the following error occurred…

[ 96%] Building CXX object src/gromacs/CMakeFiles/libgromacs.dir/selection/symrec.cpp.o
make[2]: *** No rule to make target ‘/opt/AMDAPPSDK-3.0/lib/x86_64/libOpenCL.so’, needed by ‘lib/libgromacs.so.6.0.0’. Stop.
make[1]: *** [CMakeFiles/Makefile2:4922: src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

How can I resolved this?


Looks like you got the device drivers installed correctly given the clinfo output you show.

At the point where you installed ocl-icd-opencl-dev thing should have worked and it is not expected that the cmake script returned the “OpenCL is not supported.” error. What distribution are you running? Can you run the distribution-provided clinfo to see if that detects the devices?


Thank you very much for your answer.
I reinstall the ocl-icd-opencl-dev again. And remove the build.
It worked!
Thank you very much!
Right now I would like to run the simulation to know the interaction of two organic molecules. Do you have any suggestion?
I will closed this issue and open a new one on how to perform simulation on two organic small molecules.

Quick summarize. I leave the way I fix the issue here.
Anyone with AMD GPU user should install AMD driver first.
I also get stuck at installing AMD driver first.
It will need you to turn on 32 bit support on your Linux OS to get it installed (you can find how right here). Also, you will need to get the latest driver from the website for your Linux. Install the AMD driver pro with OpenCL support followed by installing ocl-icd-opencl-dev and then run the command cmake … -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=OpenCL.
Note that AMD_APP_SDK may not be needed.
Then you can build GROMACS as usual.