dailenson / SDT

This repository is the official implementation of Disentangling Writer and Character Styles for Handwriting Generation (CVPR23).
MIT License
956 stars 81 forks source link

如何在intel Mac 不用gpu只用cpu? #44

Open Stone-0211 opened 7 months ago

Stone-0211 commented 7 months ago

如题,我无法使用cuda,每次都报错,想看看能不能换成cpu,时间长点没关系 或者大佬能不能帮我看看为啥cuda会报错: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead. warnings.warn( /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=ResNet18_Weights.IMAGENET1K_V1. You can also use weights=ResNet18_Weights.DEFAULT to get the most up-to-date weights. warnings.warn(msg) Traceback (most recent call last): File "/Users/shuang/Downloads/SDT-master 2/test.py", line 115, in main(opt) File "/Users/s/Downloads/SDT-master 2/test.py", line 39, in main gly_dec_layers= cfg.MODEL.GLY_DEC_LAYERS).to('cuda') ^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1160, in to return self._apply(convert) ^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 810, in _apply module._apply(fn) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 810, in _apply module._apply(fn) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 833, in _apply param_applied = fn(param) ^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1158, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/torch/cuda/init.py", line 289, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

dailenson commented 7 months ago

搜索一下代码里面,主要是train.pytest.py,把cuda改成cpu就好

Stone-0211 commented 7 months ago

改完了,但他又报这个错了😂:FileNotFoundError: [Errno 2] No such file or directory: 'checkpoint_path' 请问要把checkpoint-iter199999.pth放哪里啊? 谢谢!

dailenson commented 7 months ago

改完了,但他又报这个错了😂:FileNotFoundError: [Errno 2] No such file or directory: 'checkpoint_path' 请问要把checkpoint-iter199999.pth放哪里啊? 谢谢!

随便放个地方,然后把路径记下来,替换掉checkpoint_path就好啦

Stone-0211 commented 7 months ago

又报了这个错😓: RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

dailenson commented 7 months ago

test.py中的第41行改成model_weight = torch.load(opt.pretrained_model, map_location='cpu')

Stone-0211 commented 7 months ago

这又是啥原因?TypeError: cannot pickle 'Environment' object

dailenson commented 7 months ago

这又是啥原因?TypeError: cannot pickle 'Environment' object

参见issue#23,把test.py里的DataLoadernum_workers改成0

Stone-0211 commented 7 months ago

好像cuda又出问题了:AssertionError: Torch not compiled with CUDA enabled

dailenson commented 7 months ago

好像cuda又出问题了:AssertionError: Torch not compiled with CUDA enabled

等我抽空整理一个cpu版本