File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed
crates/find_cuda_helper/src Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -109,15 +109,31 @@ pub fn find_cuda_lib_dirs() -> Vec<PathBuf> {
109
109
110
110
#[ cfg( not( target_os = "windows" ) ) ]
111
111
pub fn find_cuda_lib_dirs ( ) -> Vec < PathBuf > {
112
- if let Some ( root_path) = find_cuda_root ( ) {
113
- vec ! [
114
- root_path. clone( ) . join( "lib64" ) ,
115
- root_path. clone( ) . join( "lib" ) ,
116
- root_path. join( "lib" ) . join( "stubs" ) ,
117
- ]
118
- } else {
119
- vec ! [ ]
112
+ let mut candidates = read_env ( ) ;
113
+ candidates. push ( PathBuf :: from ( "/opt/cuda" ) ) ;
114
+ candidates. push ( PathBuf :: from ( "/usr/local/cuda" ) ) ;
115
+ for e in glob:: glob ( "/usr/local/cuda-*" ) . unwrap ( ) {
116
+ if let Ok ( path) = e {
117
+ candidates. push ( path)
118
+ }
119
+ }
120
+
121
+ let mut valid_paths = vec ! [ ] ;
122
+ for base in & candidates {
123
+ let lib = PathBuf :: from ( base) . join ( "lib64" ) ;
124
+ if lib. is_dir ( ) {
125
+ valid_paths. push ( lib. clone ( ) ) ;
126
+ valid_paths. push ( lib. join ( "stubs" ) ) ;
127
+ }
128
+ let base = base. join ( "targets/x86_64-linux" ) ;
129
+ let header = base. join ( "include/cuda.h" ) ;
130
+ if header. is_file ( ) {
131
+ valid_paths. push ( base. join ( "lib" ) ) ;
132
+ valid_paths. push ( base. join ( "lib/stubs" ) ) ;
133
+ continue ;
134
+ }
120
135
}
136
+ valid_paths
121
137
}
122
138
123
139
#[ cfg( target_os = "windows" ) ]
You can’t perform that action at this time.
0 commit comments