安装 amdgpu-pro 驱动程序后,无法让 OpenCl 识别 AMD GPU(RX 480)

安装 amdgpu-pro 驱动程序后,无法让 OpenCl 识别 AMD GPU(RX 480)

安装 AMD 的 GPU 驱动程序后这里(特别是“适用于 Ubuntu 20.04 的 20.20 版本”),OpenCl 不起作用。

为了安装驱动程序,我解压了 tarball 并./amdgpu-pro-install -y --opencl=pal,legacy --headless运行sudo usermod -a -G video $LOGNAME

该命令lspci -nn | grep -E 'VGA|Display'正确显示已安装的 GPU: 01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] [1002:67df] (rev c7)

但是当我运行时clinfo我得到的输出

Number of platforms                               2
  Platform Name                                   AMD Accelerated Parallel Processing
  Platform Vendor                                 Advanced Micro Devices, Inc.
  Platform Version                                OpenCL 2.1 AMD-APP (3110.6)
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_amd_event_callback cl_amd_offline_devices 
  Platform Host timer resolution                  1ns
  Platform Extensions function suffix             AMD

  Platform Name                                   Clover
  Platform Vendor                                 Mesa
  Platform Version                                OpenCL 1.1 Mesa 20.0.8
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd
  Platform Extensions function suffix             MESA

  Platform Name                                   AMD Accelerated Parallel Processing
Number of devices                                 0

  Platform Name                                   Clover
Number of devices                                 0

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  No platform
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   No platform
  clCreateContext(NULL, ...) [default]            No platform
  clCreateContext(NULL, ...) [other]              No platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  No devices found in platform

经过一番搜索后,我尝试运行sudo apt-get install ocl-icd-opencl-dev,但它已经安装好了。

任何帮助都将不胜感激。如果您认为有任何信息可以补充且对您有用,请告诉我。

答案1

我在尝试通过 ssh 使用 OpenCl(用于挖矿)时遇到了同样的问题(尽管我使用 --headless 选项安装了 amdgpu-pro)。如果您通过 ssh 遇到此问题,请尝试在启动后直接登录并在那里启动特定过程作为解决方法。如果它不起作用并且您通过 ssh 安装了 amdgpu-pro,请尝试直接安装它。

答案2

归因

首先,我尝试为特定显卡安装 amdgpu 软件,但无法成功运行。此外,./amdgpu-installamdgpu-pro-install脚本会长时间冻结终端。因此,经过反复尝试,我按照以下步骤操作这个视频,它解释了 TurboSlayer 在回答中建议的更详细的过程这个问题。我通过检查和的输出来验证指令是否有效clinforocminfo并观察这两个命令的输出中确实识别了相应的卡。

代码

# Source of commands: https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html

yes | sudo apt update
yes | sudo apt dist-upgrade
yes | sudo apt install libnuma-dev
yes | sudo apt install wget gnupg2
wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add -
echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/debian/ ubuntu main' | sudo tee /etc/apt/sources.list.d/rocm.list
yes | sudo apt update
sudo reboot

# Open a terminal after reboot and run:
yes | sudo apt install rocm-dkms
sudo usermod -aG video $LOGNAME
sudo usermod -aG render $LOGNAME
echo 'export PATH=$PATH:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin' | sudo tee -a /etc/profile.d/rocm.sh


# Wait till everything is installed and reboot again
sudo reboot

# Verify the videocards are recognized with:
clinfo
rocminfo

接下来,需要确保 OpenCL 确实找到了这些卡。默认情况下,OpenCL 会在其自己的目录中查找amdocl64_40000.icd(这只是它显然需要的一些文件,我以为它由于 40000 代码而依赖于卡,但看起来并非如此)。但是,使用此过程时该文件实际上位于文件夹中,rocm因此请使用以下命令更改该文件的路径amdocl64_40000.icd

sudo nano /etc/OpenCL/vendors/amdocl64_40000.icd

并改变:

libamdocl64.so

到:

/opt/rocm/opencl/lib/libamdocl64.so

现在您不应该Failed to list OpenCL platforms再收到该错误。这最后一步的来源

笔记

amdgpu-install该脚本是在全新安装的 Ubuntu 20.04 上运行的。卸载nor文件后,上述说明不起作用。我猜想在此过程中amdgpu-pro-install也使用了某些东西,但我想这在全新安装的 Ubuntu 20.04 中没有发生。rocmamdgpu-install

相关内容