Skip to content

Commit

Permalink
fix libcuda path when running in WSL (chapel-lang#24347)
Browse files Browse the repository at this point in the history
This PR adds the ability to detect if we are using an NVidia GPU while
running in Windows Subsystem for Linux (WSL) and make appropriate
additions to properly detect the location of `libcuda`.

This change was needed because WSL has a special configuration w.r.t.
the GPU drivers where the drivers are installed only in Windows and then
made available to WSL.

TESTING:

- [x] paratest on chapdl-nvidia `[Summary: #Successes = 176 | #Failures
= 0 | #Futures = 6]`
- [x] code targeting GPU compiles and runs in WSL with an NVidia GPU

[reviewed by @e-kayrakli - thanks!]
  • Loading branch information
arezaii authored Mar 8, 2024
2 parents b7c8f8d + 7549de5 commit c5a4776
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions util/chplenv/chpl_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def get(flag='host'):
return platform_val


@memoize
def is_wsl():
name = (platform.uname().release).lower()
if name.endswith('-microsoft') or name.endswith('-microsoft-standard-wsl2'):
return True

@memoize
def get_mac_os_version():
release, version, machine = platform.mac_ver()
Expand Down
5 changes: 4 additions & 1 deletion util/chplenv/compile_link_args_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ def get_runtime_link_args(runtime_subdir):
sdk_path = chpl_gpu.get_sdk_path(gpu_type)
if gpu_type == "nvidia":
system.append("-L" + os.path.join(sdk_path, "lib64"))
system.append("-lcuda")
system.append("-lcudart")
if chpl_platform.is_wsl():
# WSL needs to link with libcuda that belongs to the driver hosted in Windows
system.append("-L" + os.path.join("/usr", "lib", "wsl", "lib"))
system.append("-lcuda")
elif gpu_type == "amd":
lib_path = os.path.join(sdk_path, "lib")
system.append("-L" + lib_path)
Expand Down

0 comments on commit c5a4776

Please sign in to comment.