Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for CuDNN-8.7+ load bug #98644

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions aten/src/ATen/native/cudnn/Conv_v8.cpp
Expand Up @@ -40,6 +40,10 @@ C10_DIAGNOSTIC_POP()
#include <ATen/ops/empty.h>
#endif

#ifdef __linux__
#include <dlfcn.h>
#endif

namespace at { namespace native {

namespace {
Expand All @@ -62,6 +66,22 @@ uint8_t getAlignment(const Tensor &t) {
}

cudnn_frontend::Tensor getTensorDescriptorWithTypeVirtual(const Tensor &t, const int64_t id, const uint8_t alignment, const cudnnDataType_t dataType, const at::MemoryFormat memory_format, const bool _virtual) {
#if defined(__linux__) && !defined(FBCODE_CAFFE2) && CUDNN_MAJOR == 8 && CUDNN_MINOR > 5
// Workaround for cudnn error handling deficiency, that results in a crash on Ubuntu-22+
// if `libnvrtc.so` is not found on the system, which strictly speaking is not necessary
// for usecases below
// See https://github.com/pytorch/pytorch/issues/97041
static C10_UNUSED auto cudnn_cnn_infer_handler = [] {
void *handle = dlopen("libcudnn_cnn_infer.so.8", RTLD_LAZY);
char *err = dlerror();
if (!handle) {
TORCH_WARN("Attempt to open cnn_infer failed: handle=", handle, " error: ", err);
} else if (err) {
TORCH_WARN("Applied workaround for CuDNN issue, install nvrtc.so");
}
return handle;
}();
#endif
auto sizes = t.sizes();
auto strides = t.strides();
bool channels_last = memory_format == at::MemoryFormat::ChannelsLast ||
Expand Down