接:
代码调试的坑:
在demo.py中,关于yaml.load(),由于版本升级安全性考虑,需要传入Loader=的位置参数
可用一下语句代替: yaml.safe_load(f)
def load_checkpoints(config_path, checkpoint_path, cpu=False):
with open(config_path) as f:
config = yaml.safe_load(f)
关于错误:
AssertionError: Torch not compiled with CUDA enableds
输入一下代码检查:
import torch
print(torch.__version__)
print(torch.cuda.is_available())
如果输出的结果是False,那么说明当前的Pytorch版本无法使用显卡。
查看CUDA版本信息:
nvcc --version
CUDA版本下载地址:
CUDA 工具包 | NVIDIA Developerhttps://developer.nvidia.cn/zh-cn/cuda-toolkitCUDA Toolkit 11.6 Downloads | NVIDIA Developerhttps://developer.nvidia.com/cuda-downloadsCUDA Toolkit Archive | NVIDIA DeveloperPrevious releases of the CUDA Toolkit, GPU Computing SDK, documentation and developer drivers can be found using the links below. Please select the release you want from the list below, and be sure to check www.nvidia.com/drivers for more recent production drivers appropriate for your hardware configuration.https://developer.nvidia.com/cuda-toolkit-archive
根据自己的CUDA版本在Pytorch官网查看并安装可用的版本,参考链接如下:
https://download.pytorch.org/whl/torch_stable.htmlhttps://download.pytorch.org/whl/torch_stable.htmlhttps://download.pytorch.org/whl/cu102/torch_stable.htmlhttps://download.pytorch.org/whl/cu102/torch_stable.html
PyTorch的下载,保证版本一致性
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch