-
Notifications
You must be signed in to change notification settings - Fork 20
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
Locate nvvm
, libdevice
and nvrtc
from nvidia-cuda-nvcc-cu12
wheels
#155
base: main
Are you sure you want to change the base?
Locate nvvm
, libdevice
and nvrtc
from nvidia-cuda-nvcc-cu12
wheels
#155
Conversation
if sp is not None: | ||
dso_dir = os.path.join( | ||
sp, | ||
"nvidia", | ||
"cuda_nvcc", | ||
"nvvm", | ||
dso_dir | ||
) | ||
dso_path = os.path.join(dso_dir, dso_path) | ||
if os.path.exists(dso_path): | ||
return str(Path(dso_path).parent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented on this in NVIDIA/cuda-python#441 (comment), but we may want to just consider trying to import the nvidia
package and then subsequently trying to import the cuda_nvcc
package from the nvidia
package instead of manually traversing the paths? We can then use nvidia.cuda_nvcc.__path__
which always resolve to sp/nvidia/cuda_nvcc
and will follow the general python rules for which package takes priority properly.
numba_cuda/numba/cuda/cuda_paths.py
Outdated
def _get_nvvm_wheel(): | ||
site_paths = [ | ||
site.getusersitepackages() | ||
] + site.getsitepackages() + ["conda", None] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to add a conda
path here? If someone installed the wheel in a conda environment it would presumably be in the site.getsitepackages()
?
numba_cuda/numba/cuda/cuda_paths.py
Outdated
# The SONAME is taken based on public CTK 12.x releases | ||
if sys.platform.startswith("linux"): | ||
dso_dir = "lib64" | ||
# Hack: libnvvm from Linux wheel | ||
# does not have any soname (CUDAINST-3183) | ||
dso_path = "libnvvm.so" | ||
elif sys.platform.startswith("win32"): | ||
dso_dir = "bin" | ||
dso_path = "nvvm64_40_0.dll" | ||
else: | ||
raise AssertionError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can pull this out of the site_paths
loop I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might also be good to raise the exception with some explanation of what is wrong?
('Debian package', get_debian_pkg_libdevice()), | ||
('NVIDIA NVCC Wheel', get_libdevice_wheel()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to be looking for this ahead of the Debian package, otherwise Debian-packaged versions will always get in front of the wheel.
numba_cuda/numba/cuda/cuda_paths.py
Outdated
] | ||
libdevice_ctk_dir = get_system_ctk('nvvm', 'libdevice') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we move the system toolkit after the Debian-packaged version? I think we want to preserve the order if we can.
numba_cuda/numba/cuda/cuda_paths.py
Outdated
# Keep only the max (most recent version) of the bitcode files. | ||
out = max(candidates, default=None) | ||
if by == "NVIDIA NVCC Wheel": | ||
# The NVVM path is a directory, not a file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the relevance of the NVVM path here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realised this is a copy/paste error from below.
numba_cuda/numba/cuda/cuda_paths.py
Outdated
# The NVVM path is a directory, not a file | ||
out = os.path.join(libdir, "libdevice.10.bc") | ||
else: | ||
# Search for pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's called libdevice.10.bc
in all supported toolkit versions, so this logic is probably no longer needed - will check and update here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked - even back in 11.2 it is called libdevice.10.bc
- so we don't need to search and choose from a set of candidates anymore.
candidates = find_lib('nvvm', path) | ||
path = max(candidates) if candidates else None | ||
if by == "NVIDIA NVCC Wheel": | ||
# The NVVM path is a directory, not a file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't figure out what this comment means / adds - can you explain / reword / delete it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions on the diff - in addition, do we plan to add a CI config that installs these from wheels so that we know it will continue to work?
Yes, I'll see about adding a separate CI job for this |
|
||
# remove cuda-nvvm-12-5 leaving libnvvm.so from nvidia-cuda-nvcc-cu12 only | ||
apt-get update | ||
apt remove --purge cuda-nvvm-12-5 -y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This combined with the addition of nvidia-cuda-nvcc-cu12
was the easiest way I could think of to get to the relevant test environment, but I'm by no means married to it, this would have to be dynamic wrt the minor version as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get the installed package name with something like
CUDA_NVVM_PACKAGE=`dpkg --get-selections | grep cuda-nvvm | awk '{print $1}'`
I've merged this branch with main (fbbc040) and tested on
But can't get rid of
I'm getting the error:
Context: |
Hi @ZzEeKkAa , there's a couple pieces of this that are still WIP, I think you'll probably run into bugs right now. I'm working this PR over the next few days so hopefully some more updates soon. |
Closes #66
Closes #65
WIP, current code finds nvvm/libdevice which is enough to launch kernels, nvrtc support is next. Logic vendored from
nvmath-python