Running 3 AMD GPUs (RX 570, RX 570, RX 470) On Ubuntu A Comprehensive Guide

by StackCamp Team 76 views

Running multiple AMD GPUs in a Linux environment, particularly Ubuntu, can be a rewarding endeavor for tasks like cryptocurrency mining, scientific computing, or machine learning. However, it often presents unique challenges, especially concerning driver compatibility and system stability. This guide addresses how to configure three AMD GPUs—specifically, two RX 570s and one RX 470—on a modern Ubuntu system without encountering crashes. We'll delve into the intricacies of driver installation, configuration, and troubleshooting, ensuring a smooth and efficient multi-GPU setup.

Understanding the Challenges of Multi-GPU Setups

Before diving into the steps, it's crucial to understand the challenges involved in running multiple GPUs. The primary hurdle is ensuring that the operating system and drivers correctly recognize and utilize all the cards without conflicts. This is especially pertinent when dealing with a mix of GPUs, such as the RX 570 and RX 470, which, while similar, may require specific driver configurations.

Driver compatibility is paramount. Using the wrong drivers can lead to system instability, poor performance, or even the inability to detect all GPUs. Furthermore, power management, cooling, and system resources become critical factors when running multiple high-performance GPUs. Insufficient power, inadequate cooling, or memory constraints can all contribute to system crashes and suboptimal performance.

In the context of Ubuntu, which is a popular choice for mining rigs and GPU-intensive applications, the open-source nature of the operating system offers flexibility but also necessitates a deeper understanding of system configuration. This guide aims to provide that understanding, offering a step-by-step approach to successfully running your multi-GPU setup.

Step-by-Step Guide to Configuring Your GPUs

1. Initial System Setup and Preparation

Before installing any drivers, it's essential to prepare your system. Start by ensuring your Ubuntu installation is up-to-date. Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade

These commands update the package lists and upgrade the installed packages to their latest versions. This is a crucial step to avoid compatibility issues with newer drivers. Next, ensure your system has the necessary dependencies for building and installing drivers. Install the required packages using:

sudo apt install build-essential dkms linux-headers-$(uname -r)

build-essential provides essential tools for compiling software, dkms (Dynamic Kernel Module Support) allows drivers to be automatically rebuilt when the kernel is updated, and linux-headers provides the necessary header files for the current kernel. With these prerequisites in place, you're ready to proceed with driver installation.

2. Identifying Your GPUs

To ensure the drivers are correctly installed, you need to identify your GPUs. Use the lspci command to list all PCI devices:

lspci | grep VGA

This command filters the output to show only VGA-compatible devices, which include your GPUs. Note down the device IDs for each GPU, as this information may be needed later for specific driver configurations. Typically, the output will display the model names (RX 570, RX 470) and their corresponding PCI addresses. This step is vital for verifying that all GPUs are recognized by the system before proceeding further.

3. Installing AMD Drivers

The most critical step is installing the correct AMD drivers. AMD offers both open-source and proprietary drivers, each with its own advantages and disadvantages. For most modern AMD GPUs, including the RX 570 and RX 470, the open-source drivers (amdgpu) are often sufficient and well-integrated into the Linux kernel. However, for specific workloads or newer cards, the proprietary amdgpu-pro drivers might offer better performance.

For this guide, we'll focus on installing the open-source drivers first, as they are generally easier to set up and maintain. Ubuntu usually includes these drivers by default, but it's good practice to ensure they are properly configured. If you encounter issues, you can later explore the amdgpu-pro drivers.

To begin, verify that the amdgpu drivers are active. You can check this by running:

lsmod | grep amdgpu

If the amdgpu module is listed, it means the open-source drivers are loaded. If not, you may need to manually enable them. This usually involves modifying the kernel boot parameters. Edit the /etc/default/grub file using your favorite text editor (e.g., nano or vim):

sudo nano /etc/default/grub

Find the line starting with GRUB_CMDLINE_LINUX_DEFAULT and add the following parameters:

radeon.si_support=0 amdgpu.si_support=1 radeon.cik_support=0 amdgpu.cik_support=1

These parameters instruct the kernel to use the amdgpu drivers for Southern Islands (SI) and Sea Islands (CIK) GPUs, which include the RX 570 and RX 470. Save the file and update GRUB:

sudo update-grub

Reboot your system for the changes to take effect. After rebooting, recheck if the amdgpu module is loaded using lsmod. If you still encounter issues, consult the AMDGPU troubleshooting documentation for further assistance.

4. Configuring the Integrated Graphics

A key part of your setup is using the integrated AMD graphics for your monitor while dedicating the discrete GPUs (RX 570s and RX 470) for compute tasks like hashing. This configuration can improve performance and stability. To achieve this, you need to configure your system to use the integrated graphics as the primary display adapter.

The exact steps vary depending on your motherboard's BIOS/UEFI settings. Typically, you need to enter the BIOS setup (usually by pressing Delete, F2, or F12 during boot) and look for an option related to primary display adapter or graphics device. Set this option to the integrated graphics. Save the changes and exit the BIOS setup.

Once the system boots, Ubuntu should use the integrated graphics for the display. You can verify this by checking the output of lspci | grep VGA. The integrated graphics should be listed as the primary display adapter. With the display handled by the integrated graphics, the discrete GPUs are free to focus on their computational tasks.

5. Addressing Common Issues and Troubleshooting

Even with careful configuration, you might encounter issues. One common problem is system crashes, often indicated by a frozen screen or an error message. These crashes can be caused by driver conflicts, insufficient power, overheating, or misconfigured settings.

If you experience crashes, start by checking your system logs. The /var/log/syslog file contains valuable information about system events, including driver errors. Use a text editor or the tail command to examine the log file:

sudo tail -f /var/log/syslog

Look for error messages related to amdgpu or other graphics-related modules. These messages can provide clues about the cause of the crashes. Another potential issue is overheating. Ensure your GPUs have adequate cooling. Check the temperature of your GPUs using tools like sensors or radeontop. If the temperatures are consistently high, consider improving your cooling solution. This might involve adding more fans, using liquid cooling, or ensuring proper airflow in your system case.

Power supply is another critical factor. Running three GPUs can draw significant power, and an insufficient power supply can lead to system instability. Ensure your power supply unit (PSU) has enough wattage to handle the combined power draw of your GPUs and other components. Consult your GPU specifications and PSU documentation to calculate your system's power requirements. If necessary, upgrade to a higher-wattage PSU.

Driver conflicts can also cause crashes. If you have previously installed other graphics drivers, they might conflict with the amdgpu drivers. Try removing any old drivers using the appropriate uninstall tools or package manager commands. A clean driver installation can often resolve compatibility issues.

6. Optimizing Performance and Stability

Once your GPUs are running without crashing, you can focus on optimizing performance and stability. This involves fine-tuning various settings and monitoring your system's behavior. One important aspect is power management. AMD GPUs offer different power profiles, and selecting the right profile can improve performance or reduce power consumption. You can adjust the power profile using tools like rocm-smi or through configuration files. Experiment with different profiles to find the optimal balance between performance and power efficiency.

Another optimization technique is adjusting the GPU clock speeds and memory timings. Overclocking can boost performance, but it also increases power consumption and heat generation. Be cautious when overclocking, and monitor your GPU temperatures closely. Underclocking, on the other hand, can reduce power consumption and heat, which can be beneficial for long-term stability. Tools like amdconfig (if using amdgpu-pro drivers) or third-party utilities can be used to adjust clock speeds and memory timings.

Monitoring your system's performance is crucial. Use tools like radeontop, htop, and sensors to track GPU utilization, memory usage, CPU load, and temperatures. Regular monitoring helps you identify bottlenecks and potential issues. If you notice consistently high utilization or temperatures, you might need to adjust your configuration or upgrade your hardware.

7. Exploring Alternative Drivers (AMDGPU-PRO)

If you encounter issues with the open-source amdgpu drivers or need specific features, you can explore the proprietary amdgpu-pro drivers. These drivers often provide better performance for certain workloads and support additional features like OpenCL and Vulkan. However, they can be more challenging to install and maintain.

To install the amdgpu-pro drivers, you need to download the appropriate package from the AMD website. Make sure to select the version that matches your Ubuntu distribution and kernel version. The installation process typically involves running a script provided in the downloaded package. Follow the instructions carefully, as the installation process can vary depending on the driver version.

Before installing amdgpu-pro, it's recommended to remove any existing amdgpu drivers. This can prevent conflicts and ensure a clean installation. Use the package manager to remove any amdgpu-related packages. After installing amdgpu-pro, you might need to configure additional settings, such as setting environment variables or creating configuration files. Consult the AMD documentation for detailed instructions.

Keep in mind that amdgpu-pro drivers are not always as well-integrated into the Linux ecosystem as the open-source drivers. You might encounter compatibility issues or need to perform manual configurations to get everything working correctly. However, for certain use cases, the performance benefits of amdgpu-pro can outweigh the challenges.

Conclusion

Running multiple AMD GPUs on Ubuntu requires careful planning and configuration, but it's a feasible and rewarding endeavor. By following this guide, you can successfully set up your RX 570 and RX 470 GPUs without crashes, optimizing your system for tasks like mining or scientific computing. Remember to prioritize driver compatibility, cooling, power management, and system monitoring. With the right approach, you can harness the full potential of your multi-GPU setup.