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