@@ -82,7 +82,7 @@ func (l *nvcdilib) newDriverVersionDiscoverer(version string) (discover.Discover
82
82
83
83
// NewDriverLibraryDiscoverer creates a discoverer for the libraries associated with the specified driver version.
84
84
func (l * nvcdilib ) NewDriverLibraryDiscoverer (version string ) (discover.Discover , error ) {
85
- libraryPaths , err := getVersionLibs (l .logger , l .driver , version )
85
+ libraryPaths , libCudaDirectoryPath , err := getVersionLibs (l .logger , l .driver , version )
86
86
if err != nil {
87
87
return nil , fmt .Errorf ("failed to get libraries for driver version: %v" , err )
88
88
}
@@ -115,6 +115,12 @@ func (l *nvcdilib) NewDriverLibraryDiscoverer(version string) (discover.Discover
115
115
updateLDCache , _ := discover .NewLDCacheUpdateHook (l .logger , libraries , l .nvidiaCDIHookPath , l .ldconfigPath )
116
116
discoverers = append (discoverers , updateLDCache )
117
117
118
+ environmentVariable := & discover.EnvVar {
119
+ Name : "LIBCUDA_SO_PARENT_DIRECTORY_CONTAINER_PATH" ,
120
+ Value : libCudaDirectoryPath ,
121
+ }
122
+ discoverers = append (discoverers , environmentVariable )
123
+
118
124
d := discover .Merge (discoverers ... )
119
125
120
126
return d , nil
@@ -202,39 +208,41 @@ func NewDriverBinariesDiscoverer(logger logger.Interface, driverRoot string) dis
202
208
// getVersionLibs checks the LDCache for libraries ending in the specified driver version.
203
209
// Although the ldcache at the specified driverRoot is queried, the paths are returned relative to this driverRoot.
204
210
// This allows the standard mount location logic to be used for resolving the mounts.
205
- func getVersionLibs (logger logger.Interface , driver * root.Driver , version string ) ([]string , error ) {
211
+ func getVersionLibs (logger logger.Interface , driver * root.Driver , version string ) ([]string , string , error ) {
206
212
logger .Infof ("Using driver version %v" , version )
207
213
208
214
libCudaPaths , err := cuda .New (
209
215
driver .Libraries (),
210
216
).Locate ("." + version )
211
217
if err != nil {
212
- return nil , fmt .Errorf ("failed to locate libcuda.so.%v: %v" , version , err )
218
+ return nil , "" , fmt .Errorf ("failed to locate libcuda.so.%v: %v" , version , err )
213
219
}
214
- libRoot := filepath .Dir (libCudaPaths [0 ])
220
+ libCudaDirectoryPath := filepath .Dir (libCudaPaths [0 ])
215
221
216
222
libraries := lookup .NewFileLocator (
217
223
lookup .WithLogger (logger ),
218
224
lookup .WithSearchPaths (
219
- libRoot ,
220
- filepath .Join (libRoot , "vdpau" ),
225
+ libCudaDirectoryPath ,
226
+ filepath .Join (libCudaDirectoryPath , "vdpau" ),
221
227
),
222
228
lookup .WithOptional (true ),
223
229
)
224
230
225
231
libs , err := libraries .Locate ("*.so." + version )
226
232
if err != nil {
227
- return nil , fmt .Errorf ("failed to locate libraries for driver version %v: %v" , version , err )
233
+ return nil , "" , fmt .Errorf ("failed to locate libraries for driver version %v: %v" , version , err )
228
234
}
229
235
230
236
if driver .Root == "/" || driver .Root == "" {
231
- return libs , nil
237
+ return libs , libCudaDirectoryPath , nil
232
238
}
233
239
240
+ libCudaDirectoryPath = driver .RelativeToRoot (libCudaDirectoryPath )
241
+
234
242
var relative []string
235
243
for _ , l := range libs {
236
244
relative = append (relative , strings .TrimPrefix (l , driver .Root ))
237
245
}
238
246
239
- return relative , nil
247
+ return relative , libCudaDirectoryPath , nil
240
248
}
0 commit comments