From a8cdae41ebbfc3d881a5252299cc9ebcea01d044 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 Mar 2024 15:10:10 +0100 Subject: [PATCH] Cycles: Disable OpenImageDenoise support for AMD GPUs in Blender 4.1 In older drivers with an integrated GPU, this may crash. This not only affects HIP, but also can crash when using Cycles with an NVIDIA or Intel GPU in combination with an AMD CPU. Fixes for this are expected to be coming, but there will not be enough time for user testing, and it is difficult to be certain that the fix is complete. So to be careful, this is postponed until it has had more testing. --- intern/cycles/device/device.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 0a2378eb679..d871149bd87 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -208,6 +208,27 @@ vector Device::available_types() return types; } +static void device_oidn_init_once() +{ + static bool initialized = false; + + if (initialized == false) { + /* Disable OIDN for HIP until it has been tested to be stable on more systems. + * + * In older drivers with an integrated GPU, this may crash with message: + * "hipErrorNoBinaryForGpu: Unable to find code object for all current devices". + * + * This also affects systems which have for example an NVIDIA GPU as OIDN + * initializes all device types together. */ +#ifdef _WIN32 + _putenv_s("OIDN_DEVICE_HIP", "0"); +#else + setenv("OIDN_DEVICE_HIP", "0", true); +#endif + initialized = true; + } +} + vector Device::available_devices(uint mask) { /* Lazy initialize devices. On some platforms OpenCL or CUDA drivers can @@ -216,6 +237,8 @@ vector Device::available_devices(uint mask) thread_scoped_lock lock(device_mutex); vector devices; + device_oidn_init_once(); + #if defined(WITH_CUDA) || defined(WITH_OPTIX) if (mask & (DEVICE_MASK_CUDA | DEVICE_MASK_OPTIX)) { if (!(devices_initialized_mask & DEVICE_MASK_CUDA)) { @@ -314,6 +337,8 @@ string Device::device_capabilities(uint mask) thread_scoped_lock lock(device_mutex); string capabilities = ""; + device_oidn_init_once(); + if (mask & DEVICE_MASK_CPU) { capabilities += "\nCPU device capabilities: "; capabilities += device_cpu_capabilities() + "\n"; -- 2.30.2