Skip to content

Commit

Permalink
c10::DriverAPI Try opening libcuda.so.1 (#113096)
Browse files Browse the repository at this point in the history
As `libcuda.so` is only installed on dev environment (i.e. when CUDAToolkit is installed), while `libcuda.so.1` is part of NVIDIA driver.
Also, this will keep it aligned with https://github.com/pytorch/pytorch/blob/a5cb8f75a7f991212fbc6d049e0bc2f9f48b07f8/aten/src/ATen/cuda/detail/LazyNVRTC.cpp#L16
Better errors in `c10::DriverAPI` on `dlopn`/`dlsym` failures
    
Cherry-pick of  following PR into release/2.1 branch
- Better errors in `c10::DriverAPI` on `dl` failure (#112995)
- `c10::DriverAPI` Try opening libcuda.so.1 (#112996)

(cherry picked from commit 3be0e1c)
(cherry picked from commit d0a80f8)
  • Loading branch information
malfet committed Nov 7, 2023
1 parent 33106b7 commit f58669b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions c10/cuda/driver_api.cpp
Expand Up @@ -10,15 +10,15 @@ namespace {
DriverAPI create_driver_api() {
#define OPEN_LIBRARIES(name, n) \
void* handle_##n = dlopen(name, RTLD_LAZY); \
TORCH_INTERNAL_ASSERT(handle_##n);
TORCH_INTERNAL_ASSERT(handle_##n, "Can't open ", #name, ": ", dlerror());

C10_FORALL_DRIVER_LIBRARIES(OPEN_LIBRARIES)
#undef OPEN_LIBRARIES
DriverAPI r{};

#define LOOKUP_ENTRY(name, n) \
r.name##_ = ((decltype(&name))dlsym(handle_##n, #name)); \
TORCH_INTERNAL_ASSERT(r.name##_)
TORCH_INTERNAL_ASSERT(r.name##_, "Can't find ", #name, ": ", dlerror())
C10_FORALL_DRIVER_API(LOOKUP_ENTRY)
#undef LOOKUP_ENTRY
return r;
Expand Down
2 changes: 1 addition & 1 deletion c10/cuda/driver_api.h
Expand Up @@ -19,7 +19,7 @@
} while (0)

#define C10_FORALL_DRIVER_LIBRARIES(_) \
_("libcuda.so", 0) \
_("libcuda.so.1", 0) \
_("libnvidia-ml.so.1", 1)

#define C10_FORALL_DRIVER_API(_) \
Expand Down

0 comments on commit f58669b

Please sign in to comment.