2121from paddle .fluid .framework import is_compiled_with_cuda # noqa: F401
2222from paddle .fluid .framework import is_compiled_with_rocm # noqa: F401
2323
24- __all__ = []
24+
25+ __all__ = [ # npqa
26+ 'get_cudnn_version' ,
27+ 'set_device' ,
28+ 'get_device' ,
29+ 'XPUPlace' ,
30+ 'is_compiled_with_xpu' ,
31+ 'is_compiled_with_cuda' ,
32+ 'is_compiled_with_rocm' ,
33+ 'is_compiled_with_npu'
34+ ]
2535
2636_cudnn_version = None
2737
@@ -113,15 +123,13 @@ def _convert_to_place(device):
113123 place = core .CPUPlace ()
114124 elif lower_device == 'gpu' :
115125 if not core .is_compiled_with_cuda ():
116- raise ValueError (
117- "The device should not be 'gpu', " \
118- "since PaddlePaddle is not compiled with CUDA" )
126+ raise ValueError ("The device should not be 'gpu', "
127+ "since PaddlePaddle is not compiled with CUDA" )
119128 place = core .CUDAPlace (ParallelEnv ().dev_id )
120129 elif lower_device == 'xpu' :
121130 if not core .is_compiled_with_xpu ():
122- raise ValueError (
123- "The device should not be 'xpu', " \
124- "since PaddlePaddle is not compiled with XPU" )
131+ raise ValueError ("The device should not be 'xpu', "
132+ "since PaddlePaddle is not compiled with XPU" )
125133 selected_xpus = os .getenv ("FLAGS_selected_xpus" , "0" ).split ("," )
126134 device_id = int (selected_xpus [0 ])
127135 place = core .XPUPlace (device_id )
@@ -135,7 +143,7 @@ def _convert_to_place(device):
135143 if avaliable_gpu_device :
136144 if not core .is_compiled_with_cuda ():
137145 raise ValueError (
138- "The device should not be {}, since PaddlePaddle is " \
146+ "The device should not be {}, since PaddlePaddle is "
139147 "not compiled with CUDA" .format (avaliable_gpu_device ))
140148 device_info_list = device .split (':' , 1 )
141149 device_id = device_info_list [1 ]
@@ -144,7 +152,7 @@ def _convert_to_place(device):
144152 if avaliable_xpu_device :
145153 if not core .is_compiled_with_xpu ():
146154 raise ValueError (
147- "The device should not be {}, since PaddlePaddle is " \
155+ "The device should not be {}, since PaddlePaddle is "
148156 "not compiled with XPU" .format (avaliable_xpu_device ))
149157 device_info_list = device .split (':' , 1 )
150158 device_id = device_info_list [1 ]
0 commit comments