|
11 | 11 | #include "utilities.hpp"
|
12 | 12 | using cl::Event;
|
13 | 13 |
|
| 14 | +static const string driver_installation_instructions = |
| 15 | +#if defined(_WIN32) |
| 16 | +R"(|----------------.------------------------------------------------------------' |
| 17 | +| AMD GPUs | https://www.amd.com/en/support/download/drivers.html |
| 18 | +| Intel GPUs | https://www.intel.com/content/www/us/en/download/785597/intel-arc-iris-xe-graphics-windows.html |
| 19 | +| Nvidia GPUs | https://www.nvidia.com/Download/index.aspx |
| 20 | +| AMD/Intel CPUs | https://www.intel.com/content/www/us/en/developer/articles/technical/intel-cpu-runtime-for-opencl-applications-with-sycl-support.html |
| 21 | +|----------------'------------------------------------------------------------. |
| 22 | +| Don't forget to reboot after installation! Press Enter to exit. | |
| 23 | +'-----------------------------------------------------------------------------')""\n"; |
| 24 | +#else // Linux |
| 25 | +string("'-----------------------------------------------------------------------------'\n")+R"( |
| 26 | +)"+string("\033[31m")+R"(.-----------------------------------------------------------------------------. |
| 27 | +| AMD GPU Drivers, which contain the OpenCL Runtime | |
| 28 | +'-----------------------------------------------------------------------------' |
| 29 | +sudo apt update && sudo apt upgrade -y |
| 30 | +sudo apt install -y g++ git make ocl-icd-libopencl1 ocl-icd-opencl-dev |
| 31 | +mkdir -p ~/amdgpu |
| 32 | +wget -P ~/amdgpu https://repo.radeon.com/amdgpu-install/6.1.3/ubuntu/jammy/amdgpu-install_6.1.60103-1_all.deb |
| 33 | +sudo apt install -y ~/amdgpu/amdgpu-install*.deb |
| 34 | +sudo amdgpu-install -y --usecase=graphics,rocm,opencl --opencl=rocr |
| 35 | +sudo usermod -a -G render,video $(whoami) |
| 36 | +rm -r ~/amdgpu |
| 37 | +sudo shutdown -r now |
| 38 | + |
| 39 | +)"+string("\033[94m")+R"(.-----------------------------------------------------------------------------. |
| 40 | +| Intel GPU Drivers are already installed, only the OpenCL Runtime is needed | |
| 41 | +'-----------------------------------------------------------------------------' |
| 42 | +sudo apt update && sudo apt upgrade -y |
| 43 | +sudo apt install -y g++ git make ocl-icd-libopencl1 ocl-icd-opencl-dev intel-opencl-icd |
| 44 | +sudo usermod -a -G render $(whoami) |
| 45 | +sudo shutdown -r now |
| 46 | + |
| 47 | +)"+string("\033[32m")+R"(.-----------------------------------------------------------------------------. |
| 48 | +| Nvidia GPU Drivers, which contain the OpenCL Runtime | |
| 49 | +'-----------------------------------------------------------------------------' |
| 50 | +sudo apt update && sudo apt upgrade -y |
| 51 | +sudo apt install -y g++ git make ocl-icd-libopencl1 ocl-icd-opencl-dev nvidia-driver-550 |
| 52 | +sudo shutdown -r now |
| 53 | + |
| 54 | +)"+string("\033[96m")+R"(.-----------------------------------------------------------------------------. |
| 55 | +| CPU Option 1: Intel CPU Runtime for OpenCL (works for both AMD/Intel CPUs) | |
| 56 | +'-----------------------------------------------------------------------------' |
| 57 | +export OCLCPUEXP_VERSION="2024.18.6.0.02_rel" |
| 58 | +export ONEAPI_TBB_VERSION="2021.13.0" |
| 59 | +sudo apt update && sudo apt upgrade -y |
| 60 | +sudo apt install -y g++ git make ocl-icd-libopencl1 ocl-icd-opencl-dev |
| 61 | +sudo mkdir -p ~/cpuruntime /opt/intel/oclcpuexp_${OCLCPUEXP_VERSION} /etc/OpenCL/vendors /etc/ld.so.conf.d |
| 62 | +sudo wget -P ~/cpuruntime https://github.com/intel/llvm/releases/download/2024-WW25/oclcpuexp-${OCLCPUEXP_VERSION}.tar.gz |
| 63 | +sudo wget -P ~/cpuruntime https://github.com/oneapi-src/oneTBB/releases/download/v${ONEAPI_TBB_VERSION}/oneapi-tbb-${ONEAPI_TBB_VERSION}-lin.tgz |
| 64 | +sudo tar -zxvf ~/cpuruntime/oclcpuexp-${OCLCPUEXP_VERSION}.tar.gz -C /opt/intel/oclcpuexp_${OCLCPUEXP_VERSION} |
| 65 | +sudo tar -zxvf ~/cpuruntime/oneapi-tbb-${ONEAPI_TBB_VERSION}-lin.tgz -C /opt/intel |
| 66 | +echo /opt/intel/oclcpuexp_${OCLCPUEXP_VERSION}/x64/libintelocl.so | sudo tee /etc/OpenCL/vendors/intel_expcpu.icd |
| 67 | +echo /opt/intel/oclcpuexp_${OCLCPUEXP_VERSION}/x64 | sudo tee /etc/ld.so.conf.d/libintelopenclexp.conf |
| 68 | +sudo ln -sf /opt/intel/oneapi-tbb-${ONEAPI_TBB_VERSION}/lib/intel64/gcc4.8/libtbb.so /opt/intel/oclcpuexp_${OCLCPUEXP_VERSION}/x64 |
| 69 | +sudo ln -sf /opt/intel/oneapi-tbb-${ONEAPI_TBB_VERSION}/lib/intel64/gcc4.8/libtbbmalloc.so /opt/intel/oclcpuexp_${OCLCPUEXP_VERSION}/x64 |
| 70 | +sudo ln -sf /opt/intel/oneapi-tbb-${ONEAPI_TBB_VERSION}/lib/intel64/gcc4.8/libtbb.so.12 /opt/intel/oclcpuexp_${OCLCPUEXP_VERSION}/x64 |
| 71 | +sudo ln -sf /opt/intel/oneapi-tbb-${ONEAPI_TBB_VERSION}/lib/intel64/gcc4.8/libtbbmalloc.so.2 /opt/intel/oclcpuexp_${OCLCPUEXP_VERSION}/x64 |
| 72 | +sudo ldconfig -f /etc/ld.so.conf.d/libintelopenclexp.conf |
| 73 | +sudo rm -r ~/cpuruntime |
| 74 | + |
| 75 | +)"+string("\033[33m")+R"(.-----------------------------------------------------------------------------. |
| 76 | +| CPU Option 2: PoCL | |
| 77 | +'-----------------------------------------------------------------------------' |
| 78 | +sudo apt update && sudo apt upgrade -y |
| 79 | +sudo apt install -y g++ git make ocl-icd-libopencl1 ocl-icd-opencl-dev pocl-opencl-icd |
| 80 | + |
| 81 | +)"+string("\033[0m"); |
| 82 | +#endif // Linux |
| 83 | + |
14 | 84 | struct Device_Info {
|
15 | 85 | cl::Device cl_device; // OpenCL device
|
16 | 86 | cl::Context cl_context; // multiple devices in the same context can communicate buffers
|
@@ -120,7 +190,12 @@ inline vector<Device_Info> get_devices(const bool print_info=true) { // returns
|
120 | 190 | }
|
121 | 191 | }
|
122 | 192 | if((uint)cl_platforms.size()==0u||(uint)devices.size()==0u) {
|
123 |
| - print_error("There are no OpenCL devices available. Make sure that the OpenCL 1.2 Runtime for your device is installed. For GPUs it comes by default with the graphics driver, for CPUs it has to be installed separately."); |
| 193 | + print_message("No OpenCL devices are available. Please install the drivers for your GPU(s) and/or the CPU Runtime for OpenCL. Instructions:", "Error", 12); |
| 194 | + print(driver_installation_instructions); |
| 195 | +#ifdef _WIN32 |
| 196 | + wait(); |
| 197 | +#endif // Windows |
| 198 | + exit(1); |
124 | 199 | }
|
125 | 200 | if(print_info) {
|
126 | 201 | println("\r|----------------.------------------------------------------------------------|");
|
|
0 commit comments