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