diff options
| author | Joshua Bakita <jbakita@cs.unc.edu> | 2025-06-17 16:34:24 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2025-06-17 16:34:24 -0400 |
| commit | e0cb12762d048e388a81cffae3e96bfe2bd672cc (patch) | |
| tree | 50f2717acd52e40a8aeac52d7bb56622649cfbae | |
| parent | 89177fce34edb5ad0059a41548888d05588cc1c5 (diff) | |
Remove dependency on patchelf and use /usr/lib instead of /lib for install
patchelf seems unreliable (--add-needed was not working in version
0.9), and it can be replaced with a simple sed command.
While on the original test system, /lib was a symlink to /usr/lib,
this does not seem to generally be the case, and CUDA is installed
in /usr/lib.
| -rw-r--r-- | Makefile | 18 | ||||
| -rw-r--r-- | README.md | 2 |
2 files changed, 11 insertions, 9 deletions
| @@ -22,7 +22,9 @@ libsmctrl.a: libsmctrl.c libsmctrl.h | |||
| 22 | # ----- CUDA Wrapper ----- | 22 | # ----- CUDA Wrapper ----- |
| 23 | libcuda.so.1: libsmctrl.c libsmctrl.h | 23 | libcuda.so.1: libsmctrl.c libsmctrl.h |
| 24 | $(CC) $< -shared -o $@ -fPIC -DLIBSMCTRL_WRAPPER $(CFLAGS) $(LDFLAGS) | 24 | $(CC) $< -shared -o $@ -fPIC -DLIBSMCTRL_WRAPPER $(CFLAGS) $(LDFLAGS) |
| 25 | patchelf libcuda.so.1 --add-needed libcuda.so | 25 | @# Replace dynamic symbol dependency on libcuda.so.1 with libcuda.so |
| 26 | @# Could also be done via patchelf --replace-needed libcuda.so.1 libcuda.so libcuda.so.1 | ||
| 27 | sed -i "s/libcuda.so.1\x00/libcuda.so\x00\x00\x00/g" libcuda.so.1 | ||
| 26 | 28 | ||
| 27 | # ----- Utilities ----- | 29 | # ----- Utilities ----- |
| 28 | # Use static linking with tests to avoid LD_LIBRARY_PATH issues | 30 | # Use static linking with tests to avoid LD_LIBRARY_PATH issues |
| @@ -71,20 +73,20 @@ clean: | |||
| 71 | 73 | ||
| 72 | install: libcuda.so.1 | 74 | install: libcuda.so.1 |
| 73 | @# Check that CUDA is installed first | 75 | @# Check that CUDA is installed first |
| 74 | test -f /lib/$(ARCH)/libcuda.so.*.* | 76 | test -f /usr/lib/$(ARCH)/libcuda.so.*.* |
| 75 | @# Change libcuda.so link to bypass libcuda.so.1 | 77 | @# Change libcuda.so link to bypass libcuda.so.1 |
| 76 | sudo ln -sf /lib/$(ARCH)/libcuda.so.*.* /lib/$(ARCH)/libcuda.so | 78 | sudo ln -sf /usr/lib/$(ARCH)/libcuda.so.*.* /usr/lib/$(ARCH)/libcuda.so |
| 77 | @# Remove libcuda.so.1 symlink | 79 | @# Remove libcuda.so.1 symlink |
| 78 | sudo rm /lib/$(ARCH)/libcuda.so.1 | 80 | sudo rm /usr/lib/$(ARCH)/libcuda.so.1 |
| 79 | @# Install wrapper as libcuda.so.1 | 81 | @# Install wrapper as libcuda.so.1 |
| 80 | sudo cp libcuda.so.1 /lib/$(ARCH)/libcuda.so.1 | 82 | sudo cp libcuda.so.1 /usr/lib/$(ARCH)/libcuda.so.1 |
| 81 | 83 | ||
| 82 | remove: | 84 | remove: |
| 83 | @# Test that our library in installed first | 85 | @# Test that our library in installed first |
| 84 | test ! -L /lib/$(ARCH)/libcuda.so.1 | 86 | test ! -L /usr/lib/$(ARCH)/libcuda.so.1 |
| 85 | @# Overwrite install with original symlinks | 87 | @# Overwrite install with original symlinks |
| 86 | sudo ln -sf libcuda.so.1 /lib/$(ARCH)/libcuda.so | 88 | sudo ln -sf libcuda.so.1 /usr/lib/$(ARCH)/libcuda.so |
| 87 | sudo ln -sf /lib/$(ARCH)/libcuda.so.*.* /lib/$(ARCH)/libcuda.so.1 | 89 | sudo ln -sf /usr/lib/$(ARCH)/libcuda.so.*.* /usr/lib/$(ARCH)/libcuda.so.1 |
| 88 | 90 | ||
| 89 | run_tests: tests | 91 | run_tests: tests |
| 90 | ./libsmctrl_test_global_mask | 92 | ./libsmctrl_test_global_mask |
| @@ -91,7 +91,7 @@ The resultant `benchmark` binary should be portable to any system with an equiva | |||
| 91 | As an alternative to modifying your application, `libsmctrl` can be installed system-wide, and partitions for each application can be set via the `nvtaskset` tool. | 91 | As an alternative to modifying your application, `libsmctrl` can be installed system-wide, and partitions for each application can be set via the `nvtaskset` tool. |
| 92 | The `nvtaskset` tool works very similarly to the Linux CPU-affinity-setting tool `taskset`. | 92 | The `nvtaskset` tool works very similarly to the Linux CPU-affinity-setting tool `taskset`. |
| 93 | 93 | ||
| 94 | To install `libsmctrl` system-wide, such that all CUDA-using applications automatically load it, ensure that `patchelf` is installed (`sudo apt install patchelf`), and run: | 94 | To install `libsmctrl` system-wide, such that all CUDA-using applications automatically load it, run: |
| 95 | ``` | 95 | ``` |
| 96 | make libcuda.so.1 install | 96 | make libcuda.so.1 install |
| 97 | ``` | 97 | ``` |
