pytorch profiler使用:
with torch.profiler.profile(schedule=torch.profiler.schedule(wait=0,\
warmup=10,active=3,repeat=1),on_trace_ready=torch.profiler.tensorboard_trace_handler('./log'), \
record_shapes=True, with_stack=True) as prof:
训练代码
参考:
PyTorch Profiler With TensorBoard — PyTorch Tutorials 1.13.1+cu117 documentation
PyTorch 官方博客:PyTorch Profiler v1.9 详解_HyperAI超神经的博客-CSDN博客_pytorch profiler
PyTorch 模型性能分析——PyTorch Profiler - 简书
【PyTorch】torch.profiler.profile的使用 - 知乎
PyTorch全新性能分析工具,可视化瓶颈,并集成到了VS Code - 知乎
nvidia apex安装遇到问题:cuda extensions are being compiled with a version of Cuda that does not match the version used to compile Pytorch binaries
这是由编译apex使用的cuda版本(runtime api,用nvcc可查看)和实际系统的cuda版本(driver api,用nvidia-smi可查看)不一致,需要设置CUDA_HOME环境变量使得这两者一致:
export CUDA_HOME=/usr/local/cuda-10.6/
或者
UDA_HOME=/usr/local/cuda-11.6 pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
参考:
显卡,显卡驱动,nvcc, cuda driver,cudatoolkit,cudnn到底是什么? - marsggbo - 博客园