@@ -82,7 +82,7 @@ func (l *nvcdilib) newDriverVersionDiscoverer(version string) (discover.Discover
8282
8383// NewDriverLibraryDiscoverer creates a discoverer for the libraries associated with the specified driver version.
8484func (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 )
8686 if err != nil {
8787 return nil , fmt .Errorf ("failed to get libraries for driver version: %v" , err )
8888 }
@@ -116,6 +116,12 @@ func (l *nvcdilib) NewDriverLibraryDiscoverer(version string) (discover.Discover
116116 disableDeviceNodeModification := l .hookCreator .Create (DisableDeviceNodeModificationHook )
117117 discoverers = append (discoverers , disableDeviceNodeModification )
118118
119+ environmentVariable := & discover.EnvVar {
120+ Name : "NVIDIA_CTK_LIBCUDA_DIR" ,
121+ Value : libCudaDirectoryPath ,
122+ }
123+ discoverers = append (discoverers , environmentVariable )
124+
119125 d := discover .Merge (discoverers ... )
120126
121127 return d , nil
@@ -203,39 +209,41 @@ func NewDriverBinariesDiscoverer(logger logger.Interface, driverRoot string) dis
203209// getVersionLibs checks the LDCache for libraries ending in the specified driver version.
204210// Although the ldcache at the specified driverRoot is queried, the paths are returned relative to this driverRoot.
205211// 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 ) {
207213 logger .Infof ("Using driver version %v" , version )
208214
209215 libCudaPaths , err := cuda .New (
210216 driver .Libraries (),
211217 ).Locate ("." + version )
212218 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 )
214220 }
215- libRoot := filepath .Dir (libCudaPaths [0 ])
221+ libCudaDirectoryPath := filepath .Dir (libCudaPaths [0 ])
216222
217223 libraries := lookup .NewFileLocator (
218224 lookup .WithLogger (logger ),
219225 lookup .WithSearchPaths (
220- libRoot ,
221- filepath .Join (libRoot , "vdpau" ),
226+ libCudaDirectoryPath ,
227+ filepath .Join (libCudaDirectoryPath , "vdpau" ),
222228 ),
223229 lookup .WithOptional (true ),
224230 )
225231
226232 libs , err := libraries .Locate ("*.so." + version )
227233 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 )
229235 }
230236
231237 if driver .Root == "/" || driver .Root == "" {
232- return libs , nil
238+ return libs , libCudaDirectoryPath , nil
233239 }
234240
241+ libCudaDirectoryPath = driver .RelativeToRoot (libCudaDirectoryPath )
242+
235243 var relative []string
236244 for _ , l := range libs {
237245 relative = append (relative , strings .TrimPrefix (l , driver .Root ))
238246 }
239247
240- return relative , nil
248+ return relative , libCudaDirectoryPath , nil
241249}
0 commit comments