2
2
import torch
3
3
from multiprocessing import cpu_count
4
4
5
+ def config_file_change_fp32 ():
6
+ for config_file in ["32k.json" , "40k.json" , "48k.json" ]:
7
+ with open (f"configs/{ config_file } " , "r" ) as f :
8
+ strr = f .read ().replace ("true" , "false" )
9
+ with open (f"configs/{ config_file } " , "w" ) as f :
10
+ f .write (strr )
11
+ with open ("trainset_preprocess_pipeline_print.py" , "r" ) as f :
12
+ strr = f .read ().replace ("3.7" , "3.0" )
13
+ with open ("trainset_preprocess_pipeline_print.py" , "w" ) as f :
14
+ f .write (strr )
5
15
6
16
class Config :
7
17
def __init__ (self ):
@@ -60,15 +70,7 @@ def device_config(self) -> tuple:
60
70
):
61
71
print ("16系/10系显卡和P40强制单精度" )
62
72
self .is_half = False
63
- for config_file in ["32k.json" , "40k.json" , "48k.json" ]:
64
- with open (f"configs/{ config_file } " , "r" ) as f :
65
- strr = f .read ().replace ("true" , "false" )
66
- with open (f"configs/{ config_file } " , "w" ) as f :
67
- f .write (strr )
68
- with open ("trainset_preprocess_pipeline_print.py" , "r" ) as f :
69
- strr = f .read ().replace ("3.7" , "3.0" )
70
- with open ("trainset_preprocess_pipeline_print.py" , "w" ) as f :
71
- f .write (strr )
73
+ config_file_change_fp32 ()
72
74
else :
73
75
self .gpu_name = None
74
76
self .gpu_mem = int (
@@ -87,10 +89,12 @@ def device_config(self) -> tuple:
87
89
print ("没有发现支持的N卡, 使用MPS进行推理" )
88
90
self .device = "mps"
89
91
self .is_half = False
92
+ config_file_change_fp32 ()
90
93
else :
91
94
print ("没有发现支持的N卡, 使用CPU进行推理" )
92
95
self .device = "cpu"
93
96
self .is_half = False
97
+ config_file_change_fp32 ()
94
98
95
99
if self .n_cpu == 0 :
96
100
self .n_cpu = cpu_count ()
0 commit comments