更新.gitignore以忽略Result.xlsx文件,修改run.py以优先使用macOS的MPS设备,优化设备设置逻辑
This commit is contained in:
parent
bef30b9c2f
commit
8025a46baa
|
|
@ -170,3 +170,4 @@ cython_debug/
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
.idea/
|
.idea/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
Result.xlsx
|
||||||
BIN
Result.xlsx
BIN
Result.xlsx
Binary file not shown.
7
run.py
7
run.py
|
|
@ -20,8 +20,11 @@ import yaml
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
# Set device
|
# Set device (prefer MPS on macOS, then CUDA, else CPU)
|
||||||
if torch.cuda.is_available() and args['device'] != 'cpu':
|
if hasattr(torch.backends, 'mps') and torch.backends.mps.is_available() and args['device'] != 'cpu':
|
||||||
|
args['device'] = 'mps'
|
||||||
|
args['model']['device'] = args['device']
|
||||||
|
elif torch.cuda.is_available() and args['device'] != 'cpu':
|
||||||
torch.cuda.set_device(int(args['device'].split(':')[1]))
|
torch.cuda.set_device(int(args['device'].split(':')[1]))
|
||||||
args['model']['device'] = args['device']
|
args['model']['device'] = args['device']
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue