Skip to content

Commit c5264ce

Browse files
andystimeclaude
andcommitted
fix: remove support libraries from LD_PRELOAD, keep only stub libraries
- GetLibraryNames() now only returns stub libraries that intercept GPU API calls - NVIDIA: libcuda.so, libnvidia-ml.so - AMD/Hygon: libamdhip64.so - Removed libteleport.so and libaccelerator from LD_PRELOAD - libteleport is loaded dynamically by stub libraries - libaccelerator is used by ggo binary, not for GPU call interception - All libraries remain available in container via /opt/gpugo/libs mount - Updated comments to clarify the distinction Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 86fa514 commit c5264ce

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

internal/studio/env.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ type GPUEnvResult struct {
5757
// GetLibraryNames returns the library names to preload for a vendor (Linux/macOS)
5858
// Note: These are the expected canonical names. Use FindActualLibraryFiles to
5959
// discover actual downloaded files which may have different names.
60+
// Only includes libraries that need to intercept GPU API calls (stub libraries).
61+
// Other libraries (libteleport, libaccelerator) are available in LD_LIBRARY_PATH but not preloaded.
6062
func GetLibraryNames(vendor GPUVendor) []string {
6163
switch vendor {
6264
case VendorNvidia:
63-
return []string{"libcuda.so", "libnvidia-ml.so", "libteleport.so", "libaccelerator_nvidia-linux-amd64.so"}
65+
// Only preload stub libraries that intercept CUDA/NVML API calls
66+
return []string{"libcuda.so", "libnvidia-ml.so"}
6467
case VendorAMD, VendorHygon:
65-
return []string{"libamdhip64.so", "libteleport.so", "libaccelerator_amd-linux-amd64.so"}
68+
return []string{"libamdhip64.so"}
6669
default:
6770
return []string{}
6871
}
@@ -71,10 +74,13 @@ func GetLibraryNames(vendor GPUVendor) []string {
7174
// FindActualLibraryFiles scans the cache directory for actual GPU library files
7275
// that should be preloaded. This handles cases where downloaded files have different
7376
// names than the canonical library names.
77+
// Note: Only stub libraries (libcuda, libnvidia, etc.) need to be in LD_PRELOAD.
78+
// Support libraries (libteleport, libaccelerator) are detected by patterns for
79+
// discovery purposes, but won't be preloaded if canonical stub libraries are found.
7480
func FindActualLibraryFiles(cachePath string, vendor GPUVendor) []string {
7581
var libs []string
7682

77-
// First try to find canonical library names
83+
// First try to find canonical library names (stub libraries only)
7884
canonicalNames := GetLibraryNames(vendor)
7985
for _, name := range canonicalNames {
8086
libPath := filepath.Join(cachePath, name)
@@ -83,18 +89,20 @@ func FindActualLibraryFiles(cachePath string, vendor GPUVendor) []string {
8389
}
8490
}
8591

86-
// If canonical names found, use them
92+
// If canonical names found, use them (stub libraries only)
8793
if len(libs) > 0 {
8894
return libs
8995
}
9096

9197
// Otherwise, scan for .so files that match vendor patterns
98+
// Patterns include support libraries for discovery, but only stub libraries
99+
// will be used for LD_PRELOAD (libteleport/libaccelerator are in LD_LIBRARY_PATH)
92100
entries, err := os.ReadDir(cachePath)
93101
if err != nil {
94102
return canonicalNames // Fall back to canonical names if can't read dir
95103
}
96104

97-
// Patterns for different vendors
105+
// Patterns for different vendors (includes support libs for discovery)
98106
var patterns []string
99107
switch vendor {
100108
case VendorNvidia:

0 commit comments

Comments
 (0)